我有一个很大的问题,那就是with椭圆和opencv-python。
我知道我必须安装opencv-contrib-python才能获得一些函数,但它不能与fitellips函数一起工作。
使用时:
import cv2
cv2.fitEllipse()结果如下:
TypeError: fitEllipse() missing required argument 'points' (pos 1)但如果我现在尝试使用,例如,从图像中进行轮廓检测:
img = cv2.imread('messi5.jpg',0)
retz,bawgray=cv2.threshold(img , 110,255,cv2.THRESH_BINARY)
contours,hierarchy = cv2.findContours(bawgray,1,1)
cnt = contours
big_contour = []
maxop = 0
for i in cnt:
areas = cv2.contourArea(i)
if areas > maxop:
maxop = areas
big_contour = i
img=cv2.drawContours(img, big_contour, -1, (0,255,0), 3)
cv2.FitEllipse(big_contour)结果如下:
AttributeError: module 'cv2.cv2' has no attribute 'FitEllipse'我使用opencv-python 4.2.0.34和opencv-contrib-python 4.2.0.34
发布于 2020-05-06 07:09:51
您尚未提供cv2.fit provided的输出。此外,您还拼写错了名称。它是小写"f“的"fitEllipse”而不是"FitEllipse“。
试一试
result = img.copy()
((centx,centy), (width,height), angle) = cv2.fitEllipse(big_contour)
cv2.ellipse(result, (int(centx),int(centy)), (int(width2/),int(height2/)), angle, 0, 360, (0,0,255), 1)https://stackoverflow.com/questions/61624413
复制相似问题