Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

findContours not working properply

$
0
0
I am using findContours on a simple white circle i created on a paint application with a black back ground. The problem is that while the tutorials tell me that there should be only one contour surrounding that circle, when i output the contours, there are 2 different points. Due to this reason, i am not able to use contour approx method. Can anyone help me with this? Thanks in Advance! import cv2 import numpy as np img = cv2.imread("url.png") canny = cv2.Canny(img,0,0) imgs,cnts,hie = cv2.findContours(canny,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) cv2.namedWindow("img",cv2.WINDOW_NORMAL) cnt = cnts[1] epsilon = 0.1*cv2.arcLength(cnt,True) approx = cv2.approxPolyDP(cnt,epsilon,True) cv2.drawContours(img,approx,-1,(0,255,0),3) cv2.imshow("img",img) cv2.waitKey(0) cv2.destroyAllWindows() This is the original image(/upfiles/14483724218429244.png) This is the editied image for approximation(/upfiles/14483724673701482.png) The black and white image/(/upfiles/14483740423517343.jpeg)

Viewing all articles
Browse latest Browse all 41027

Trending Articles



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