Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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(edges, circles, Imgproc.CV_HOUGH_GRADIENT, 1, 60, 200, 20, 30, 0 ); Imgproc.HoughCircles(gray, circles, Imgproc.CV_HOUGH_GRADIENT, 1, 10, 200, 20, 40, 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 in the row but it does not show me good result.

for( int i = 0; i < circles.rows(); i++ ) { double[] data = circles.get(i, 0); x = data[0]; y = data[1]; r = (int) data[2]; }

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

for( int i = 0; i < circles.cols(); i++ ) { double[] data = circles.get(0, i); x = data[0]; y = data[1]; r = (int) data[2]; }

Any help please.

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(edges, circles, Imgproc.CV_HOUGH_GRADIENT, 1, 60, 200, 20, 30, 0 ); Mat();

Imgproc.HoughCircles(gray, circles, Imgproc.CV_HOUGH_GRADIENT, 1, 10, 200, 20, 40, 0 );

    System.out.println("#rows " + circles.rows() + " #cols " +
+ circles.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 in the row but it does not show me good result.

for( int i = 0; i < circles.rows(); circles.rows(); i++ ) { ){

    double[] data = circles.get(i, 0);
      x = data[0];
     y = data[1];
     r = (int) data[2];    data[2];

}

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

for( int i = 0; i < circles.cols(); circles.cols(); i++ ) { ){

    double[] data = circles.get(0, i);
      x = data[0];
     y = data[1];
     r = (int) data[2];    }

}

Any help please.

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(gray, circles, Imgproc.CV_HOUGH_GRADIENT, 1, 10, 200, 20, 40, 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 in the row but it does not show me good result.

for( int i = 0; i < circles.rows(); i++ ){

    double[] data = circles.get(i, 0);

    x = data[0];
    y = data[1];
    r = (int) data[2];

}

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

for( int i = 0; i < circles.cols(); i++ ){

    double[] data = circles.get(0, i);

    x = data[0];
    y = data[1];
    r = (int) data[2];    }

For example look at this image

image description

Any help please.

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(gray, circles, Imgproc.CV_HOUGH_GRADIENT, 1, 10, 200, 20, 40, 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 also does not work !!!

for( int i if (circles.cols() > 0)

          for (int x = 0; i x < circles.cols(); i++ ){

    double[] data = circles.get(0, i);

    x = data[0];
    y = data[1];
    r = (int) data[2]; 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.

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(gray, circles, Imgproc.CV_HOUGH_GRADIENT, 1, 10, 200, 20, 40, 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 also 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.

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(gray, circles, Imgproc.HoughCircles(threshold, circles, Imgproc.CV_HOUGH_GRADIENT, 1, 10, 200, 1 , gray.rows()/2 , 200, 20, 40, 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.

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(gray, circles, Imgproc.HoughCircles(threshold, 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.

click to hide/show revision 8
No.8 Revision

hough circle

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

Mat circles = new Mat();

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)

 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.