Ask Your Question
0

hough circle

asked 2015-10-06 04:46:39 -0500

User1 gravatar image

updated 2015-10-06 09:45:53 -0500

thdrksdfthmn gravatar image

How can I get the number of circles that return by hough circle using java open CV.

Mat circles = new Mat();

Imgproc.HoughCircles(grayImage, circles, Imgproc.CV_HOUGH_GRADIENT, 1 , gray.rows()/2 , 200, 20, 30, 0 );

System.out.println("#rows " + circles.rows() + " #cols " + circles.cols());

I don't know how it store the circles in Mat that has cols and rows ??

I try to get the circle from column but it does not work !!!

if (circles.cols() > 0)
    for (int x = 0; x < circles.cols(); x++) 
    {
        double vCircle[] = circles.get(0,x);
        if (vCircle == null)
            break;
        Point pt = new Point(Math.round(vCircle[0]),
        Math.round(vCircle[1]));
        int radius = (int)Math.round(vCircle[2]);
        // draw the found circle
        Core.circle(imgRGB, pt, radius, new Scalar(0,255,0), 2);
        Core.circle(imgRGB, pt, 3, new Scalar(0,255,0), 2);
     }

For example look at this image

image description

Any help please.

edit retag flag offensive close merge delete

Comments

1

Have you seen this?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-10-06 05:01:50 -0500 )edit

Strange... I'll go for a grouping circle custom function... Maybe using groupRectangles?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-10-06 09:46:54 -0500 )edit

Thank u :)

User1 gravatar imageUser1 ( 2015-10-07 05:47:42 -0500 )edit

Did this solve the problem? If so I am going to combine some answers so you can mark this solved.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-07 05:55:03 -0500 )edit

YES I increase the min distance as u said :)))

User1 gravatar imageUser1 ( 2015-10-07 06:12:46 -0500 )edit

Do mark it as solved :) Thank you!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-07 06:37:38 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-10-07 04:20:08 -0500

updated 2015-10-07 06:37:10 -0500

Copied from @thdrksdfthmn:

I would try to do a mean of the circles if their ratios are almost the same and the distances between the centers is less than the ratio. But have you tried to play with min_dist parameter? I have seen that you have set it to 10, why?

Added myself:

Increase the min_dist parameter for the circles centers as said by @thdrksdfthmn. It is the distance between two neighboring circle centers. Keep in mind that all edges in an image contribute to a possible circle, that is why HoughCircles always finds more circles than we need if you do not adapt the parameters correctly.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-10-06 04:46:39 -0500

Seen: 188 times

Last updated: Oct 07 '15