Why do I keep getting rotated rect's when they are circles? [closed]

asked 2016-01-25 11:04:40 -0600

spyderespirt0 gravatar image

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: image description

What could be causing this? Also why is it missing the entire white rectangle?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-22 14:54:23.166513

Comments

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.

kbarni gravatar imagekbarni ( 2016-01-25 11:24:04 -0600 )edit

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?

spyderespirt0 gravatar imagespyderespirt0 ( 2016-01-25 12:27:45 -0600 )edit

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.

matman gravatar imagematman ( 2016-01-25 13:24:45 -0600 )edit

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?

spyderespirt0 gravatar imagespyderespirt0 ( 2016-01-25 22:49:29 -0600 )edit

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.

kbarni gravatar imagekbarni ( 2016-01-26 02:39:53 -0600 )edit