(解決方案是在結束)不能用Spesific彩色(RGB/HSV/HSL)(解決/解決方案詳解)
當我在油漆上分析這張圖片時,線條就像RGB顏色空間中的[120,100,45]。當我將此應用於cv2.inRange時,我無法得到奇怪的結果。我不知道該怎麼做,也不知道爲什麼它沒有顯示出這種黃色(實際上看起來像黃色)車道的跡象。請幫助
EDIT1:
我覺得值僅獲得這些線路,它們分別是: 較低:0,110,0 上:160,195,80
然而,當我試圖獲得現場演奏這一行,與ImageGrab模塊(後精明和gaussblur),我得到:
我的目標是用HoughProbabilistic畫出車道,但是我看不到連續的線條,即使在現場演奏中每次都沒有線條。我很困惑,這裏的代碼:
def process_img(image):
lower_yellow = np.array([0, 110, 0])
upper_yellow = np.array([160, 195, 80])
# yellow color mask
processimagehsl = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
yellow_mask = cv2.inRange(processimagehsl, lower_yellow, upper_yellow) # and we are masking it
masked = cv2.bitwise_and(image, image, mask=yellow_mask) # and then we combine it with original image
# turned into gray
processimagecanny = cv2.Canny(masked, threshold1=150,
threshold2=300) # with canny edge detection method, we detect edges
# of only our yellow lines' edges. We used masking
# at the beginning of the code because of this.
processimagegauss = cv2.GaussianBlur(processimagecanny, (5, 5), 0) # This'Ll fix some in order to avoid noises
processedimage = regionofinterest(processimagegauss) # Let's get back to our predetermined region
lines = cv2.HoughLinesP(processedimage, 1, np.pi/180, 180, 0, 0)
return processedimage
你可以選擇與OpenCV的這個應用程序的範圍內,這裏的鏈接:http://answers.opencv.org/question/134248/how-to-define-the-lower-and-upper-range-of-a-color/
這裏就是它看起來像解釋(感謝計算器):
你能粘貼代碼和輸出你正在變得 –
opencv默認使用BGR,因此請嘗試圍繞[45,100,120]範圍或從BGR轉換爲RGB。 – Micka
Micka我試過了,沒有解決方案 –