Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7061817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:31:12+00:00 2026-05-28T04:31:12+00:00

for (int i = 0; i < circles->total; i++) { // round the floats

  • 0
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]);
     //uchar* ptr;
     //ptr = cvPtr2D(img, center.y, center.x, NULL);
     //printf("B: %d G: %d R: %d\n", ptr[0],ptr[1],ptr[2]);
     CvScalar s;

     s = cvGet2D(img,center.y, center.x);//colour of circle
    printf("B: %f G: %f R: %f\n",s.val[0],s.val[1],s.val[2]);

     // 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);

the code above detects 22 colored balls and extracts rgb value of each ball. ican use this rgb value to determine color of each ball. i am trying to implement detection of which color ball the white ball hits first. my idea was to wait for white balls centre to change(i.e. move) and the next color ball whose center changes is the ball it hits. but i am having trouble coding this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:31:12+00:00Added an answer on May 28, 2026 at 4:31 am

    You can save the previous x,y in variables, and check them every iteration, to determinate if they had changed.
    I recommend you, instead of this, to check the distance between the center of the white ball to the center of the others – a collision is when the distance is the sum of the radiuses.

    BTW, It’s not C.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im going round in circles on this. I have a class Person, eg public
I need some help here, I'm currently going round in circles. I have a
cvHoughCircles(Mat& image, vector<Vec3f>& circles, int method, double dp, double minDist, double param1=100, double param2=100,
I made one class for my object: public class circles { int coor_x; int
I drew some circles on the Form1 using GDI+ , and the center of
Still really struggling with this and appear to be going round in circles. I
int x = n / 3; // <-- make this faster // for instance
int x; printf(hello %n World\n, &x); printf(%d\n, x);
int[] mylist = { 2, 4, 5 }; IEnumerable<int> list1 = mylist; list1.ToList().Add(1); //
int n = 5; for(int i = 0;i!=n;i++)//condition != { //executing 5times } int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.