I’m working on a project that aims to detect an 8 inch diameter ball about 20 feet away from the camera, and only when it is in motion. I’m using the following technique:
- Capture image when starting the camera
- Begin frame differencing
- Convert the frame to binary with a threshold of 25
- Perform erosion and dilation to get rid of noise and segmented objects
- Use blob detection to identify objects that are roughly ball size or bigger.
- If the centroid is above a specific line we know it’s in flight and moving. Ignore anything larger or below that threshold
This worked relatively well so long as there was good contrast between the ball and background. And so long as the background didn’t change which pretty much means this doesn’t work outside.
My main issue is trying to deploy this in a new environment where the lighting is poor. The ball is really only lit from the top meaning the entire lower half of the ball is in shadow and it just gets lost in the background.
I noticed that auto exposure was resulting in a relatively dark image, perhaps incorrectly metered by a few bright ceiling lights. If I manually set the exposure I could lighten the image and get better results, but there were then many more false positives.
I think my quick fix is to install some bright lights behind the camera to better illuminate the balls. I’d like to find a more robust way to account for this though. And I’m realizing it likely will require some conditional evaluation of blobs frame over frame.
Any guidance on this would be greatly appreciated.