1 我收到错误,而不是安装所有依赖项,如 python3.6.2、numpy、opencv、open-contrib-python。 2. 错误-
File "lane.py", line 23, in <module>
cv2.imshow("result", region_of_interest(canny))
File "lane.py", line 15, in region_of_interest
cv2.fillpoly(mask, polygons, 255)
AttributeError: module 'cv2.cv2' has no attribute 'fillpoly'
3源代码-
import cv2
import numpy as np
def canny(image):
gray = cv2.cvtColor(lane_image, cv2.COLOR_RGB2GRAY)
blur = cv2.GaussianBlur(gray, (5,5), 0)
canny = cv2.Canny(blur, 50, 150)
return canny
def region_of_interest(image):
height = image.shape[0]
polygons= np.array([(200, height), (1100, height), (550, 250)])
mask = np.zeros_like(image)
cv2.fillpoly(mask, polygons, 255)
return mask
image = cv2.imread('test_image.jpg')
lane_image = np.copy(image)
canny = canny(lane_image)
cv2.imshow("result", region_of_interest(canny))
cv2.waitkey(0)