I have seen this code that draws an outline circle and its center point to the ball detected.

// draws all detected circle and their center points.
    for (int i = 0; i < circles->total; i++)
         // round the floats to an int
         float* p = (float*)cvGetSeqElem(circles, i);
         cv::Point center(cvRound(p[0]), cvRound(p[1]));
         int radius = cvRound(p[2]);
cvScalar c;
         c = cvGet2D(img, center.x, center.y);//colour of circle

         // draw the circle center
         cvCircle(img, center, 3, CV_RGB(0,255,0), -1, 8, 0 );

         // draw the circle outline
         cvCircle(img, center, radius+1, CV_RGB(0,0,255), 2, 8, 0 );

         //display coordinates
         printf("x: %d y: %d r: %d\n",center.x,center.y, radius);

I want to print the number of balls detected. How can i do that?

Edited by eve_moore: n/a

6 Years
Discussion Span
Last Post by eve_moore
std::cout << circles->total;


that was way too easy. i'll go and try it. Thank you

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.