Wednesday, July 30, 2008

Activity 11: Camera Calibration

In this activity, we were asked to transform a global coordinate system to an image-plane centric coordinate system through translation and rotation processes to calibrate a camera.

Camera calibration involves the calculation of parameters aij of a matrix A. This matrix determines the camera geometry. Below are the equations used for this activity.





To start with the activity, a picture of a checkerboard image shown below was taken. The origin was chosen to be at the lower middle part of the image, thus letting the left side be the x axis, the right side as the y axis, and the z axis as the vertical. 25 corners of the squares of the image were chosen to be measured.

Using the locate function in Scilab, the coordinates of the chosen points were determined.
These values were tabulated below with their corresponding calculated 2D coordinate values using the code. Results show that there is an ave. %difference of 1.48 and 1.82 for the y and z values respectively.

yi zi Calculated yi Calculated zi
57.95 232.7 57.02 239.29
97.74 236.8 97.05 237.22
182.26 234.46 181.02 232.41
249.71 228.01 252.74 226.59
93.72 189.88 94.94 192
161.17 196.92 162.46 193.44
213.34 186.95 212.5 186.76
284.31 178.15 289.25 176.5
53.95 142.96 53.33 144.06
73.15 149.41 73.76 145.88
164.66 151.76 160.04 153.54
227.42 140.62 227.5 141.3
51.53 98.39 51.24 97.49
127.16 110.7 126.03 109.15
177.57 108.36 173.43 110.48
243.26 92.52 242.91 94.58
67.3 59.09 69.45 56.04
125.98 69.06 123.73 68.09
161.14 71.41 155.3 75.09
223.31 54.4 221.55 56.81
83.72 17.55 86.4 17.46
137.23 33.28 137.63 32.14
174.63 31.59 168.47 31.53
222.73 15.93 218.62 15.34

The code used for this is:

chdir('F:\186\activity11');
im = imread('image3.jpg');
image = im2gray(im);
imshow(image);
x = locate(25,1);
yi = x(1,:);
zi = x(2,:);

xo = [6 4 0 0 4 0 0 0 6 5 0 0 6 2 0 0 5 2 0 0 4 1 0 0 0];
yo = [0 0 1 5 0 0 3 7 0 0 0 4 0 0 1 5 0 0 0 4 0 0 1 4 6];
zo = [10 10 10 10 8 8 8 8 6 6 6 6 4 4 4 4 2 2 2 2 0 0 0 0 0];

for i=1:length(xo)
Q1 = [xo(i) yo(i) zo(i) 1 0 0 0 0 -(yi(i)*xo(i)) -(yi(i)*yo(i)) -(yi(i)*zo(i))];
Q2 = [0 0 0 0 xo(i) yo(i) zo(i) 1 -(zi(i)*xo(i)) -(zi(i)*yo(i)) -(zi(i)*zo(i))];
d1 = yi(i);
d2 = zi(i);
end
a = inv(Q'*Q)*Q'*d;
for j = 1:length(xo)
y2 = ((a(1)*xo(j))+(a(2)*yo(j))+(a(3)*zo(j))+a(4))/((a(9)*xo(j))+(a(10)*yo(j))+(a(11)*zo(j))+1);
z2= ((a(5)*xo(j))+(a(6)*yo(j))+(a(7)*zo(j))+a(8))/((a(9)*xo(j))+(a(10)*yo(j))+(a(11)*zo(j))+1);
end

rating-9 because the ave. percentage difference between the located and calculated coordinate values is still within allowable 5% .

acknowledgement - Lei for helping me with some of the processes involved.








No comments: