Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

fitellipse not fitting

$
0
0
I get this result when fitting an ellipse to a contour (the contour is green, the fitted ellipse in blue) ![image description](/upfiles/14835800378896769.jpg) Here's the original image : ![image description](/upfiles/14835804269748794.jpg) Why doesn't it fit? Here is the code : ---------- img1 = cv2.imread(r'limb_edge_fl28_iss3628.jpg') gray1 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) # Threshold the images thresh1 = cv2.threshold(gray1, 127, 255, cv2.THRESH_BINARY)[1] contours = cv2.findContours(thresh1.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)[1] cnt1 = contours[0] # draw contours found cv2.drawContours(img1, [cnt1], 0, green, 2) # Fit an ellipse to the contours ellipse = cv2.fitEllipse(cnt1) # Draw the ellipse on the image cv2.ellipse(img1,ellipse,(255,255,0),2) cv2.imshow("ellipse fit 1", img1)

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>