Analysis

Evaluation

Distances to the targets were measured with measuring tape. Targets were always placed on the floor and all pictures were taken with my camera on the floor, positioned such that the targets would be as centered as possible within the image. The errors were as follows:

Distance Estimation Errors

Procedure

Thresholding
Using a slider found on the internet, I identified the color that best resembled tennis ball green. All pixels in the image were evaluated, and were thresholded to white if the h, s, and v value were within a certain percentage of the matching hsv values for tennis ball green.
Noise
At this point the images were blurred heavily with a disk filter then rethresholded. This both merged nearby potential groups and got rid of many small groups.
Segmenting
The white sections of the image were then marked using flood fill. To take advantage of this recursive function, the image had to be compressed.
Analysis
Further filtering eliminated the smallest groups by taking the average pixel count of the groups and blacking out any groups whose count was not greater than a defined percentage of the average. Theoretically, if one tennis ball was split into 2 larger groups, the disk blur should have been harsh enough to merge them. The centroids were measured on all groups and the 4 with the centroids closest to the center of the image were chosen as tennis balls.
Triangulation
Although my camera’s ppi (pixel per inch) information was available online, I had difficulty finding a focal length. I ran my pipeline several times using the h/d = h_prime/f equation and the known distance of each image to find an appropriate focal length. I then plugged this focal length into the same equation to find the distance for each image.

Error Analysis

The largest source of my error was the focal length. This number is finicky to begin with as the camera should theoretically change its focal length during autofocus. My initial choice of focal length, 123, resulted in extremely low errors for the large target (<2.5%), but resulted in a larger overestimation of distance in the case of the smaller target, particularly at 16 ft (11.9%). 123 was the average of the focal lengths for the large target. While within the acceptable bounds, I chose instead to use a focal length that evened out errors for the small target as well, 119. Surprisingly, compression of the image did not result in unreasonable error. While I cannot compare my error outputs with analysis on uncompressed images, the compressed image errors were all well under the maximum allowed error of 15% and contributed to much faster runtimes which facilitated experimenting with different image processing methods. Small error may have come from the blurring, however this step also contributed much more good than any apparent harm it enacted.

Original and Processing Photos

Big Target

From 2 ft

original thresholded segmented data association

From 4 ft

original thresholded segmented data association

From 8 ft

original thresholded segmented data association

From 16 ft

original thresholded segmented data association

Small Target

From 2 ft

original thresholded segmented data association

From 4 ft

original thresholded segmented data association

From 8 ft

original thresholded segmented data association

From 16 ft

original thresholded segmented data association