Ask Your Question
0

fastest way to detect a red ball?

asked 2016-03-22 11:15:43 -0500

215 gravatar image

I at moment trying to implement a simple an robust way of detecting an red ball.

I've converted into HSV and filtered using inRange(..), such that the red ball is clear and some other noise.

But what approach would be appropriate to detect the ball?

findContour and Hough seems a bit overkill computation wise, but what other alternatives do i have. I have to detect the position of the ball at all time, so the speed of the algorithm has to be appropriate for tracking.

what do you suggest?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-03-22 12:19:26 -0500

kbarni gravatar image

I think you are looking for the image moments.

Moments mom=moments(segm_image);
int area,xc,yc;
area=mom.m00; //area of the ball in pixels
xc=mom.m10/mom.m00; //x and y center of the ball
yc=mom.m01/mom.m00;
edit flag offensive delete link more

Comments

I Wont know the distance for sure as the size of Ball of the image is not known.. I am using stereo vision

215 gravatar image215 ( 2016-03-22 12:50:05 -0500 )edit

The disadvantage of moments is, that it is executed on the whole image. So if there are just a few pixels left far away from the ball position, the center of that ball will be shifted a lot. The next question is if moments is that much faster than findContours.

Why do you think, that findContours is too slow? You can also resize your image to speed up findContours at the cost of accuracy.

matman gravatar imagematman ( 2016-03-23 16:16:55 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-03-22 11:15:43 -0500

Seen: 488 times

Last updated: Mar 22 '16