# hough circle

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

Any help please.

Have you seen this?

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

Thank u :)

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

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

Do mark it as solved :) Thank you!