I have a edge detected by Canny. And I want to extract contours of the edges.
I have checked the following post. OpenCV converting Canny edges to contours.
But it didn't deal with complex shape. e.g, circle with rectangle or circle with line.
cv::findContours() function has 2 issues. 1. Return closed contour for non closed edge, but I want non closed contour 2. Return 2 closed contours for closed edge(maybe one of the contours is for edge, and another one is for inner side of the edge, but I want one of the two.
Is there any way to solve this out? Thanks.
PS : I have uploaded the sample image.
It all depends on the parameters you choose while finding contours.
In OpenCV you can find contours using
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
and draw them
cv2.drawContours(im, contours, -1, (0, 255, 0), -1) #---set the last parameter to -1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With