我想在Python中使用opencv庫在車道檢測上運行代碼。但是,我得到一個numpy.ndarray
錯誤:OpenCV - 車道檢測'numpy.ndarray'錯誤
TypeError: 'numpy.ndarray' object is not callable
File "lane_detect.py", line 10, in <module>
line(img,(x1,y1),(x2,y2),(0,255,0),2)
這裏是我試圖運行的代碼:
from cv2 import *
from numpy import *
from matplotlib import pyplot as plt
img = imread("Lane1.png", 0)
edges = Canny(img,100,200)
lines = HoughLinesP(edges,1,pi/180,100,minLineLength=100,maxLineGap=10)
for line in lines:
x1,y1,x2,y2 = line[0]
line(img,(x1,y1),(x2,y2),(0,255,0),2)
'''for line in lines:
for ex in line:
print ex'''
imwrite('Lane1.png', img)
namedWindow("Image", WINDOW_AUTOSIZE)
namedWindow("Canny", WINDOW_AUTOSIZE)
imshow("Canny", edges)
imshow("Image", img)
waitKey(0)
destroyAllWindows()
有可能是代碼中的其他錯誤。
請在代碼中提出一些更改。
你想用'line(img,(x1,y1),(x2,y2),(0,255,0),2)'來實現什麼? – languitar
如果您想了解houghlines,可以參考openCV文檔。我正在嘗試構建一個houghline。 –
你是否能夠識別圖像中的車道? –