Why do I keep getting rotated rect's when they are circles? [closed]
I'm doing rectangle detection using canny edges and contour detection using Emgu CV (example). I keep getting rotated rect's even though the objects are circles, see below:
What could be causing this? Also why is it missing the entire white rectangle?
I suspect that you might need to run the Canny edge detector before the circle detector on this image. See what do you get by running the HoughCircles method on the cannyEdges image.
I am currently running the edge detector before the circle detection, but they don't interfere with each other at all. They are separate processes. What does running HoughCircles on the image have to do with non-existent rotated rectangles showing up?
I think the parameters for Canny don't fit to your image. Did you watch at the result of Canny edge detection? Perhabs you can also tune the parameters for ApproxPolyDP and ContourArea.
If the pixel size of your objects differ from the size of the objects in the example image, the result can differ too.
I'm not quite sure how to play with the ApproxPolyDP settings, here is what is in my program currently: CvInvoke.ApproxPolyDP(contour, approxContour, CvInvoke.ArcLength(contour, true) * .05, true); What would I tweak and what does that change?
I suggest to go step by step. Run Canny, check the result and tune the parameters. Then, if it shows correctly all the interesting contours, run the HoughCircles on the canny image and check the results, tune the parameters until the circles get detected. Then you should probably clear these areas from the canny image, to avoid a second detection. Finally run the FindContours algorithm to detect the linear contours and adjust the parameters. When the contours are OK, you can run the ApproxPolyDP.