Monday, August 11, 2008

Activity 11: Camera Calibration


The activity was done using the image below.










Letting the origin be at the lowest part of the board along the middle, coordinates of 20 corner points were measured. Using Microsoft Paint, the coordinates for each picked corner in the image was determined.






x0 = [0 1 3 0 2 0 0 0 8 3 0 0 0 0 3 8 5 1 6 0];
y0 = [0 0 0 3 0 6 7 3 0 0 8 1 6 8 0 0 0 0 0 2];
z0 = [0 1 4 5 9 11 5 7 0 12 7 10 9 0 6 8 8 10 11 1];
yi = [100 117 154 70 138 37 24 70 243 157 13 92 36 13 154 248 192 120 212 80];
zi = [234 218 163 145 62 26 156 105 251 3 115 41 68 265 123 89 86 41 26 222];for i = 1:20
Q((2*i)+1,:) = [x0(i) y0(i) z0(i) 1 0 0 0 0 -(yi(i)*x0(i)) -(yi(i)*y0(i)) -(yi(i)*z0(i))];
Q((2*i)+2,:) = [0 0 0 0 x0(i) y0(i) z0(i) 1 -(zi(i)*x0(i)) -(zi(i)*y0(i)) -(zi(i)*z0(i))];
d((2*i)+1,:) = [yi(i)];
d((2*i)+2,:) = [zi(i)];
end
Qt = Q'
a = inv(Qt*Q)*Qt*d;


//check
for j = 1:20
y2(j,:) = ((a(1))*x0(j)+(a(2))*y0(j)+(a(3))*z0(j)+a(4))/((a(9))*x0(j)+(a(10))*y0(j)+(a(11))*z0(j)+1);
z2(j,:) = ((a(5))*x0(j)+(a(6))*y0(j)+(a(7))*z0(j)+a(8))/((a(9))*x0(j)+(a(10))*y0(j)+(a(11))*z0(j)+1);
end
The code above used the equation from the manual.


The result was having an average % error of 0.7947295 and 1.245960579 in y and z respectively.


//verification for other points

x0 = [3 7 0];

y0 = [0 0 2];

z0 = [5 2 7];

for k = 1:3

y3(k,:) = ((a(1))*x0(k)+(a(2))*y0(k)+(a(3))*z0(k)+a(4))/((a(9))*x0(k)+(a(10))*y0(k)+(a(11))*z0(k)+1);

z3(k,:) = ((a(5))*x0(k)+(a(6))*y0(k)+(a(7))*z0(k)+a(8))/((a(9))*x0(k)+(a(10))*y0(k)+(a(11))*z0(k)+1);
end
The results show that the method was accurate.
Grade: 7/10 - The activity was passed late.
Acknowledgement: Jorge Presto

No comments: