We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,166 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Detecting 2 or more Circles using c++

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?

2
Contributors
2
Replies
8 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
eve_moore
Newbie Poster
6 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
std::cout << circles->total;

?

Nick Evan
Cold-a$$ donkey
Moderator
10,261 posts since Oct 2006
Reputation Points: 4,155
Solved Threads: 416
Skill Endorsements: 22
std::cout << circles->total;

?

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

eve_moore
Newbie Poster
6 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0614 seconds using 2.68MB