Over the last two weeks, I have been working on the existing code by Parth Agrawal for the estimation of the location of the green ball from images that were shot at different angles. The code had estimated the position of the ball quite well for the hi-def images but not so for the 800x600 images:
01 02 03 04

As a result of this, I have tried estimating the location of the ball using the weighted mean of the center of each contour (weighted by the contour area to an arbitrary power). Instead of choosing all contours, the contours that are larger than a particular fraction (presently 0.2) of the largest contour's area have been used for calculating this mean point. Moreover, for better detection of the hi-def images, I have tried out histogram equalization (this doesn't turn out well for the 800x600 images):
05 06 07 08

The code has successfully detected the location of the ball for 29 out of 31 images. However, contour detection has not been as smooth as location detection. For example, the location of the ball is quite accurately calculated in this 800x600 photo but this is based on a very small segment of the ball's image. I tried to fix this using adaptive thresholding but that did not work uniformly across all images:
13

One of the two undetected images had the ball under glass and hence it wasn't visible enough to detect the ball:
09 10

However, the other image contains the ball quite clearly and the code has failed to detect the correct location of the ball due to false positives:
11 12

I'm still figuring out how to fix this issue. Something that came to my mind is spliitting the image into regions based on the existing contour centers (some technique similar to Voronoi regions) and detecting the actual center from known features about the ball; for example, false positives tend to create several small contours whereas the ball tends to create fewer but larger contours. I will be testing this over the next week. In the meanwhile, I will also be checking out the existing dynamics code and adding PID control to the system.

Next Post Previous Post