Is there is a demo C/C++ OpenCV program available that does simple ball tracking from a web camera? [closed]

StackOverflow https://stackoverflow.com//questions/12700922

  •  12-12-2019
  •  | 
  •  

Question

Is there any open source or demo code available in C/C++ for OpenCV that does simple ball tracking?

Basically I want to hold a red-colored ball in front of my web camera and I want OpenCV to detect its location. If I move the ball towards the right or left of the screen the program will detect the location of the ball has changed and output its new location.

I have successfully installed Open CV 2.3.1 on the raspberry pi with a web camera, eventually I want to execute the code on the pi.

Was it helpful?

Solution

I just stumbled upon this. It is a cvBlob example and very similar to what you want to do. Source code is here here.

OTHER TIPS

This seems to be what I'm looking for:

https://github.com/tommed/tommed-opencv-examples/

There's a project I've played with a while ago called Touchless

It is perhaps a little bit too complex for what you intend to do, but there's some marker tracking code in there, and it can be useful ;)

Good luck playing with your Pi.

The example that you found - Tommed - uses the RGB to track colours.

You would do a lot better looking at the HSV plane. There is an example in the cvBlob library

However people have varying degrees of success with cvBlob on the Pi. Still the principle of HSV remains the way to go.

If you want to detect simple object such as red colored ball, you may consider using pixy camera.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top