Reputation: 390
I want to track a ping pong ball during game using opencv.
I'm not really sure how to tackle this problem. I tried using the orange color for detecting the ball each frame, via cv.inRange in RGB & HSV color space, however this did not work quite well. But could any kind of preprocessing help with that?
Also using MOG the ball can be seen quite well when moving (still a lot of noise due to moving people in the scene), was not the best way I guess.
Any tips how to achieve a ball tracking script?
Here is an image how the scene looks like in a "bad" frame (ball is in the middle above the net):
I'm happy to get any tips, thanks in advance
Upvotes: 3
Views: 1489
Reputation: 523
One possibility is to just ask people not to walk behind the table, to try to improve the performance of background subtraction/MOG. You can then crop out the players, to focus only on the table area.
There are also algorithms to detect people - e.g. HOG-based methods. https://thedatafrog.com/en/articles/human-detection-video/ includes a tutorial.
You could also try blob detection after subtracting the background, and filtering out any blobs that are too large, since you know how big the ping-pong ball is.
Another concept is to keep track of where you think the ball should be based on previous measurements.
Upvotes: 0