fitEllipse returns 比实际轮廓大两倍的椭圆
fitEllipse returns ellipses that is twice as big as the actual contour
如您所见,轮廓比拟合的椭圆小得多。下面是我用来生成椭圆的相关代码。有人可以告诉我我做错了什么吗?谢谢。
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
draw function 需要一半大小:
axes – Half of the size of the ellipse main 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)
如您所见,轮廓比拟合的椭圆小得多。下面是我用来生成椭圆的相关代码。有人可以告诉我我做错了什么吗?谢谢。
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
draw function 需要一半大小:
axes – Half of the size of the ellipse main 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)