From the lecture, this mapping is algebraically represented by the following equations where the 2D coordinates (yi,zi) are solved for using the 3D coordinates (x0,y0,z0).
In matrix form, this is written as:
and can be rewritten as: Q = ad
The transformation matrix, a, can then be solved for using:
Activity procedure:
- take a picture of the provided 3D calibration checkerboard and pick out an origin and 20 edge points.3D calibration checkerboard with chosen points marked with X's
Real-world coordinates of chosen points:
2. Use scilab to process the image and use the locate() function to find the image coordinates of the chosen points.
Image coordinates of the chosen points:
Code:
stacksize(4e7);
im=imread('C:\Documents and Settings\Endura\My Documents\186\DSC04829.jpg');
imshow(im);
x=locate()
3. Use scilab to input the chosen points into the above equation (13), and use the above
equation (15) to solve for the transformation matrix a.
Code:
xo=[8 4 0 0 0 4 0 8 4 0 0 0 4 0 8 4 0 0 0 0];
yo=[0 0 0 4 8 0 4 0 0 0 4 8 0 4 0 0 0 4 8 0];
zo=[12 12 12 12 12 9 9 6 6 6 6 6 3 3 0 0 0 0 0 1];
yi=[18 138 235 325 437 139 324 24 140 237 325 439 143 325 30 144 238 326 438 238];
zi=[430 412 399 419 444 319 322 219 222 228 224 222 129 131 8 36 60 36 6 87];
for i = 1:length(xo)
Q((2*i)-1,:) = [xo(i) yo(i) zo(i) 1 0 0 0 0 -(yi(i)*xo(i)) -(yi(i)*yo(i)) -(yi(i)*zo(i))];
Q(2*i,:) = [0 0 0 0 xo(i) yo(i) zo(i) 1 -(zi(i)*xo(i)) -(zi(i)*yo(i)) -(zi(i)*zo(i))];
d((2*i)-1,:) = yi(i);
d(2*i,:) = zi(i);
end
a = inv(Q'*Q)*Q'*d;
The following values for were obtained:
a =
- 26.918641
12.900713
- 0.7063340
238.39153
- 6.5092147
- 6.8013387
27.705465
59.226318
- 0.0239055
- 0.0275689
- 0.0016180
Testing this calibration using 3 test points, there was a discrepancy of a few pixels. The error average at less than 5% though, and this to me is an acceptable range given that there are many factors that could contribute to the distortion of the image.
i give myself a grade of 10 for this activity. i accomplished the desired calibration with minimal error.
thank you to cole for the help.
x0 | y0 | z0 |
8 | 0 | 12 |
4 | 0 | 12 |
0 | 0 | 12 |
0 | 4 | 12 |
0 | 8 | 12 |
4 | 0 | 9 |
0 | 4 | 9 |
8 | 0 | 6 |
4 | 0 | 6 |
0 | 0 | 6 |
0 | 4 | 6 |
0 | 8 | 6 |
4 | 0 | 3 |
0 | 4 | 3 |
8 | 0 | 0 |
4 | 0 | 0 |
0 | 0 | 0 |
0 | 4 | 0 |
0 | 8 | 0 |
0 | 0 | 1 |
2. Use scilab to process the image and use the locate() function to find the image coordinates of the chosen points.
Image coordinates of the chosen points:
yi | zi |
17.714286 | 429.85714 |
137.71429 | 411.85714 |
234.57143 | 399 |
324.57143 | 418.71429 |
436.85714 | 443.57143 |
139.42857 | 319.28571 |
323.71429 | 321.85714 |
23.714286 | 219 |
140.28571 | 222.42857 |
237.14286 | 227.57143 |
324.57143 | 224.14286 |
439.42857 | 221.57143 |
142.85714 | 129 |
324.57143 | 130.71429 |
29.714286 | 8.1428571 |
143.71429 | 35.571429 |
238 | 60.428571 |
326.28571 | 36.428571 |
437.71429 | 6.4285714 |
238 | 87 |
Code:
stacksize(4e7);
im=imread('C:\Documents and Settings\Endura\My Documents\186\DSC04829.jpg');
imshow(im);
x=locate()
3. Use scilab to input the chosen points into the above equation (13), and use the above
equation (15) to solve for the transformation matrix a.
Code:
xo=[8 4 0 0 0 4 0 8 4 0 0 0 4 0 8 4 0 0 0 0];
yo=[0 0 0 4 8 0 4 0 0 0 4 8 0 4 0 0 0 4 8 0];
zo=[12 12 12 12 12 9 9 6 6 6 6 6 3 3 0 0 0 0 0 1];
yi=[18 138 235 325 437 139 324 24 140 237 325 439 143 325 30 144 238 326 438 238];
zi=[430 412 399 419 444 319 322 219 222 228 224 222 129 131 8 36 60 36 6 87];
for i = 1:length(xo)
Q((2*i)-1,:) = [xo(i) yo(i) zo(i) 1 0 0 0 0 -(yi(i)*xo(i)) -(yi(i)*yo(i)) -(yi(i)*zo(i))];
Q(2*i,:) = [0 0 0 0 xo(i) yo(i) zo(i) 1 -(zi(i)*xo(i)) -(zi(i)*yo(i)) -(zi(i)*zo(i))];
d((2*i)-1,:) = yi(i);
d(2*i,:) = zi(i);
end
a = inv(Q'*Q)*Q'*d;
The following values for were obtained:
a =
- 26.918641
12.900713
- 0.7063340
238.39153
- 6.5092147
- 6.8013387
27.705465
59.226318
- 0.0239055
- 0.0275689
- 0.0016180
Testing this calibration using 3 test points, there was a discrepancy of a few pixels. The error average at less than 5% though, and this to me is an acceptable range given that there are many factors that could contribute to the distortion of the image.
i give myself a grade of 10 for this activity. i accomplished the desired calibration with minimal error.
thank you to cole for the help.
No comments:
Post a Comment