首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FitEllipse opencv-python >4

FitEllipse opencv-python >4
EN

Stack Overflow用户
提问于 2020-05-06 06:53:12
回答 1查看 1.2K关注 0票数 1

我有一个很大的问题,那就是with椭圆和opencv-python。

我知道我必须安装opencv-contrib-python才能获得一些函数,但它不能与fitellips函数一起工作。

使用时:

代码语言:javascript
复制
import cv2
cv2.fitEllipse()

结果如下:

代码语言:javascript
复制
TypeError: fitEllipse() missing required argument 'points' (pos 1)

但如果我现在尝试使用,例如,从图像中进行轮廓检测:

代码语言:javascript
复制
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)

结果如下:

代码语言:javascript
复制
AttributeError: module 'cv2.cv2' has no attribute 'FitEllipse'

我使用opencv-python 4.2.0.34和opencv-contrib-python 4.2.0.34

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-06 07:09:51

您尚未提供cv2.fit provided的输出。此外,您还拼写错了名称。它是小写"f“的"fitEllipse”而不是"FitEllipse“。

试一试

代码语言:javascript
复制
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)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61624413

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档