python - Anomaly with Ellipse Fitting when using cv2.ellipse with different parameters? -


i using opencv 2.4.11 python 2.7.9 on windows 8.1. trying fit ellipses onto contours , came across can't figure out.

when call cv2.fitellipse , return value , pass return value directly cv2.ellipse following code, ellipses drawn onto screen perfect , make optimal fit around contours:

contours, hierarchy = cv2.findcontours(binaryimage,cv2.retr_external,cv2.chain_approx_none)  ind, cont in enumerate(contours):     elps = cv2.fitellipse(cont)     #feed elps directly cv2.ellipse     cv2.ellipse(displayframe,elps,(0,0,255))  cv2.imshow("perfectly fitted ellipses", displayframe) 

the results above

enter image description here

however, when try parse actual ellipse parameters , draw ellipse manually passing in parameters (see code below), creates "bloated" version of ellipse gives comfortable (yet annoying) bracket of space around contour, follows:

contours, hierarchy = cv2.findcontours(binaryimage,cv2.retr_external,cv2.chain_approx_none)  ind, cont in enumerate(contours):     (x,y),(ma,ma),angle = cv2.fitellipse(cont)     #feed parsed parameters cv2.ellipse     cv2.ellipse(displayframe,(x,y),(ma, ma),angle,0,360,(0,0,255))  cv2.imshow("ellipses not fitting contours properly",displayframe) 

the results annoying phenomena are:

enter image description here

yes, know using first method solves problem drawing correct ellipses. want know why doing because, in actual fact, need parameters of ellipses in order blob tracking , if parameters parsed end giving wide unfitting ellipses that, accurate? problem cv2.ellipse() drawing function? ideas on going wrong? ellipse parameters coming out of cv2.fitellipse function accurate?

you plotting width , height of returned bounding box. should plot half width , height, since axes of ellipse half width , height of bounding box

cv2.ellipse(displayframe,(x,y),(ma/2, ma/2),angle,0,360,(0,0,255)) 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -