Lab 2: Vision

Name: Zachary Dawson
Andrew ID: zsd

Photo collection:
For this lab, I collected photographs of the 15in and 5in targets with the camera of my Lg G2 phone at 2ft, 4ft, 8ft, and 16ft away from the front of the target board. To do this for the 15in target board, I first noticed that the tiles on the floor were exactly one foot square. I then proceeded to align the face of the target with the edge of one of the tiles, center the camera on the center of the board (which put the camera at 10in above the ground), and move the camera back perpendicularly from the face of the board by 2, 4, 8, and 16 tiles (maintaining the 10in height with a yardstick held perpendicularly to the ground). At each distance, I rotated the camera so that the target was about centered in the frame, focused the camera on the target, and took a picture. I used a similar procedure in capturing images of the 5in target. To collect these photos, I centered the camera on the board and moved it back perpendicularly to the board to distances of 2ft, 4ft, 8ft, and 16ft as measured by a measuring tape I laid on the ground perpendicular to the board. A measuring tape was used here since the target was 30.5in and the camera was held at 35in with a yard stick, thereby keeping the measuring tape largely out of the image and reducing a source of error. At each distance away from the board, I rotated the camera so that the target was about centered in the frame, focused the camera on the target, and took a picture. Finally, I uploaded the images to my computer for use in the lab.

Image processing:
Process shown here with the 15 in target square 16 ft from the camera.
To see the intermediate images for both targets at each distance, see the bottom of the page

Initial image

Initial image

Thresholded image

Thresholded image

Segmented image

Segmented image

Filtered and data-associated image
The red box indicates the estimated location of the target square and the yellow squares indicate the center of the centroids making up the corners of the box.

Filtered and data-associated image

Error graph for 5 in target

5 in error graph

Percent error graph for 5 in target

5 in percent error graph

Error graph for 15 in target

15 in error graph

Percent error graph for 15 in target

15 in percent error graph

Analysis of Sources of Error:

In general, my estimate error tended to increase the farther away from the target the camera was, with the estimates for the 15 in target getting progressively lower than the true value and the estimates for the 5 in target getting progressively higher. Several factors contributed to this error in my system, including; non-uniform lighting in the room, the design of the tennis balls, and the effects of discretizing a continuous image.

To begin with, the non-uniform lighting in the room caused shadows to be cast on some parts of some of the balls. This thereby caused the thresholding to only identify misshapen portions of the balls, skewing the size of the target square and affecting the accuracy of the triangulation. For instance, in the image of the 5 in target at 96 in from the camera, the bottom portions of both of the bottom tennis balls are cast in shadow, causing the thresholding algorithm to only identify the upper parts of the balls as two oval shapes instead of two full sized circles. Since only the tops of the balls were detected, the centroids were calculated to be higher in the image than they should have been, thereby causing the estimated square to be smaller than it actually was. Finally, when the triangulation algorithm was run, it took the smaller square to mean that the target was farther away, resulting in the distance estimation to be almost 9% greater than the actual distance (the largest error of any of the 5 in estimations).

In addition to the non-uniform lighting, error was introduced at close distances due to the design of the ball itself. Since the tennis balls have white lines on them, the thresholding of the images, at close distances, sometimes results in one ball being broken up into multiple, distinct yellow segments separated by the white lines. Then, depending on which segments are selected by the square-finder algorithm, the square can end up being larger or smaller than it should be, skewing the triangulation estimates. This can be most clearly seen in the image of the 15 in target at 24 in from the camera. In this case, the fractured portion of the bottom left ball selected to be used by the square-finder algorithm is slightly below the actual midpoint of the ball, thereby causing the estimated square to be slightly larger than it should be. This means that when the triangulation algorithm was run, it indicated that the target was slightly closer to the camera than it actually was, introducing the small amount of error found in the 24 in image.

Finally, simply discretizing the continuous input image caused error in the distance estimation. The reason for this is that as the camera is moved farther away from the target, the target gets smaller and smaller in the image, meaning it is represented by fewer of the definite number of pixels. As the distance between the camera and the target gets greater, the change in distance represented by the loss of a pixel from the width of the image also increases according to basic trigonometry. This means that at larger distances, the range of possible distances represented by a particular target width in the image gets larger. As an exaggerated example, this could mean that when the target is 100 pixels wide, it could be anywhere between 100 and 110 inches away, but when the target is 10 pixels wide it could be anywhere between 1000 and 2000 inches away due to the discretization of the image. This would thereby cause the triangulated distance to be either larger or smaller than the actual distance. This phenomenon could explain why, in general, the error in my estimated distances increased as the camera moved farther away from the target.

In conclusion, error in my estimates was introduced in part by non-uniform lighting, the design of the tennis ball, and the discretization of the images.


Images for all test distances and target sizes:


5 in target at 24 in

Initial image

Initial image

Thresholded image

Thresholded image

Segmented image

Segmented image

Filtered and data-associated image
Filtered and data-associated image

5 in target at 48 in

Initial image

Initial image

Thresholded image

Thresholded image

Segmented image

Segmented image

Filtered and data-associated image
Filtered and data-associated image

5 in target at 96 in

Initial image

Initial image

Thresholded image

Thresholded image

Segmented image

Segmented image

Filtered and data-associated image
Filtered and data-associated image

5 in target at 192 in

Initial image

Initial image

Thresholded image

Thresholded image

Segmented image

Segmented image

Filtered and data-associated image
Filtered and data-associated image

15 in target at 24 in

Initial image

Initial image

Thresholded image

Thresholded image

Segmented image

Segmented image

Filtered and data-associated image
Filtered and data-associated image

15 in target at 48 in

Initial image

Initial image

Thresholded image

Thresholded image

Segmented image

Segmented image

Filtered and data-associated image
Filtered and data-associated image

15 in target at 96 in

Initial image

Initial image

Thresholded image

Thresholded image

Segmented image

Segmented image

Filtered and data-associated image
Filtered and data-associated image

15 in target at 192 in

Initial image

Initial image

Thresholded image

Thresholded image

Segmented image

Segmented image

Filtered and data-associated image
Filtered and data-associated image