16,015,504 members

See more:

We have a circle moving on a screen. How to find the lowest height that the circle goes on the screen

For example, on a 200 x 200 pixel screen, we have a circle with a diameter of 10 pixels. This circle is randomly moving on this screen. How can I find out to what height the lowest part of this circle has gone down, for example, to show that this circle has not gone below the height of 35 pixels?

**What I have tried:**

For example, on a 200 x 200 pixel screen, we have a circle with a diameter of 10 pixels. This circle is randomly moving on this screen. How can I find out to what height the lowest part of this circle has gone down, for example, to show that this circle has not gone below the height of 35 pixels?

C#

CircleF[] circles = CvInvoke.HoughCircles(grayFrame, HoughModes.Gradient, 2.0, 20.0, 100.0, 45.0, 34, 39); foreach (CircleF circle in circles) { CvInvoke.Circle(fieldMask2, Point.Round(circle.Center), , (int)circle.Radius, new Bgr(Color.White).MCvScalar, 1); }

Comments

The documentation at OpenCV: Feature Detection[^] helps you. The returned data gives the position and size of the found circles, so you should be able to get the anser from that information.

Permalink

Share this answer

This sounds like a homework question. You know the diameter, so you know the height of the object. If the x, y position is the center of the circle, then the Y - radius is the bottom of the circle. Pretty simple math.

Permalink

Share this answer

Comments

payam mohammadi
17-Jun-23 5:15am

the problem is that , i dont know what is the X and Y (coordinate) of center of circle , because circle is finding by houghCircles (EMGU CV) in an image , by code i know only radius of circle is between 34 to 39

Graeme_Grant
17-Jun-23 5:50am

You can't draw a circle without coordinates and size, typically the radius. So your question makes no sense.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900

bottom is at 200

if(Circle_center + 10 == 200){ "you're on screen bottom" \ }

It's by Math and bounds of your 2 objects : the circle, and the screen all border