Showing posts with label exercise 5. Show all posts
Showing posts with label exercise 5. Show all posts

Wednesday, March 23, 2011

Exercise 5, Code Improvement

We thought that, except for cropping the processed image, the best way to improve the correct detection ratio of the found balls and reduce false detections would be to substitute the cvFindContours function currently used (which finds any closed contour) with a more specialized function, in this case cvHughCircles. This enables us to specifically look only for circles instead of contours. At first, we made a small standalone program that enables you to load a saved picture and will apply grayscaling and Gaussian filtering before attempting to find circles in the picture.

Testing the algorithm, we obtain some nice results:















The thicker red circle around the blue ball is the one our algorithm has found.
Then we proceed to substitute the necessary code in the auball2 plugin. One downside that still remains is that finding the balls correctly still greatly depends on lighting conditions, as the image fed into the cvHughCircles function is heavily filtered beforehand.

Tuesday, February 15, 2011

Exercise 5, Image analysis

The U and V values for the two balls are showed below.

Red:   umin=114   umax=130   vmin=136   vmax=154
Blue:   umin=130   umax=147  vmin=115   vmax=129

Exercise 5, Task 2. Theta

To continue with the camera calibration we need to find the angle theta on the robot's Y axis.
To achieve this we took a picture; then found the middle of the picture's corespondent point on the floor and measured the distance x from that specific point to the base of the camera, also on the floor.
The center of the picture correspondence on the floor - the end of the ruler. 
Then the height to the camera from the floor, z, was measured. We have:

x = 1.297m
z = 0.415m
theta = arctan ( x / y ) = arctan ( 0.415 / 1.297 ) = 17,743 deg 
theta = 0.309675 rad

Exercise 5, Camera parameters

We started by calculating the focal length of the camera.

Formula used: f = xi * z / x where:
x - the width of an object
z - the distance from the object to the camera
xi - the width of the object in the picture taken

We have set the robot so it seen the center of an A4 peace of paper, at the distance of 1m.
The width of the paper, as seen in the picture was 201px:




So we know the objects physical width: x = 0.297m
We have measured the object's width in the picture: xi = 201px
Stated before: z = 1m
This yields to:
f = 201px * 1m / 0.297m
f = 677px (at the picture's resolution of 752x480)