Python 3.x 开放式;cv";错误显示cv2没有带“的属性”;fillpoly“;
我正在制作一个程序来检测车道,它说cv2没有属性Python 3.x 开放式;cv";错误显示cv2没有带“的属性”;fillpoly“;,python-3.x,Python 3.x,我正在制作一个程序来检测车道,它说cv2没有属性fillpoly,即使我安装了pip“opencv” 代码如下: import cv2 import numpy as np def canny(image): greyscale_image = cv2.cvtColor(imagecopy, cv2.COLOR_RGB2GRAY) smothened_image = cv2.GaussianBlur(greyscale_image, (5, 5), 0) edged_
fillpoly
,即使我安装了pip“opencv”
代码如下:
import cv2
import numpy as np
def canny(image):
greyscale_image = cv2.cvtColor(imagecopy, cv2.COLOR_RGB2GRAY)
smothened_image = cv2.GaussianBlur(greyscale_image, (5, 5), 0)
edged_image = cv2.Canny(smothened_image, 50, 150)
return edged_image
def region_of_interst(image):
height = image.shape[0]
polygons = np.array([
[(200, height), (1100, height), (550, 250)]
])
mask = np.zeros_like(image)
cv2.fillPolly(mask, polygons, 255)
return mask
image = cv2.imread('test_image.jpg')
imagecopy = np.copy(image)
greyscale_image = cv2.cvtColor(imagecopy, cv2.COLOR_RGB2GRAY)
smothened_image = cv2.GaussianBlur(greyscale_image, (5, 5), 0)
edged_image = cv2.Canny(smothened_image, 50, 150)
canny = canny(imagecopy)
cv2.imshow('image2', region_of_interst(canny))
cv2.waitKey(0)
以下是错误:
我想你的拼写有误。您的代码用两个L表示
fillPolly()
,而不是fillPoly()
。