【问题标题】:fitEllipse returns ellipses that is twice as big as the actual contour [duplicate]fitEllipse 返回两倍于实际轮廓的椭圆[重复]
【发布时间】:2016-10-15 22:42:08
【问题描述】:

如您所见,轮廓远小于拟合椭圆。下面是我用来生成椭圆的相关代码。有人可以告诉我我做错了什么吗?谢谢。

cv2.drawContours(orig, contour,-1, (0, 255, 0),3) #draw the green contour on image "orig"
(center, size, angle) = cv2.fitEllipse(contour) #get best fit Ellipse from contour
cv2.ellipse(grey_scale,(int(round(center[0])),int(round(center[1]))),(int(round(size[0])),int(round(size[1]))),int(round(angle)),0,360,(0,255,0),1) # draw ellipse on image "grey_scale" with the statistics gathered from second line

【问题讨论】:

    标签: python-2.7 opencv contour


    【解决方案1】:

    draw function 需要一半大小:

    axes – 椭圆主轴大小的一半。

    一个更简单的方法是:

    cv2.drawContours(orig, contour,-1, (0,255,0), 3)
    my_ellipse = cv2.fitEllipse(contour)
    cv2.ellipse(grey_scale, my_ellipse, (0,255,0), 1)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-05
      • 2019-07-08
      • 2021-06-10
      相关资源
      最近更新 更多