$29.99
CSE 473/573 - Computer Vision and Image Processing
Project #1
1 Rotation Matrix (5 points)
Figure 1 illustrates the transformation from coordinate xyz to XYZ: 1)rotate around z axis with
α = 45◦
to get x
0
y
0
z
0 axis; 2) rotate around x
0 axis with β = 30◦
to get x
00y
00z
00; 3) rotate around z
00
axis with γ = 60◦
to get XYZ.
• Design a program to get the rotation matrix from xyz to XYZ.
• Design a program to get the rotation matrix from XYZ to xyz.
Figure 1: Illustration of Eular angles.
2 Camera Calibration (5 points)
Preliminary.1.
The projection from world coordinate to image plane can be indicated by intrinsic parameters
(Camera) and extrinsic parameters(World). From world coordinate to camera coordinate, the
extrinsic parameters can be used as
M = Min · Mex =
fx 0 ox
0 fy oy
0 0 1
·
r11 r12 r13 Tx
r21 r22 r23 Ty
r31 r32 r33 Tz
m11 m12 m13 m14
m21 m22 m23 m24
m31 m32 m33 m34
=
fxr11 + oxr31 fxr12 + oxr32 fxr13 + oxr33 fxTx + oxTz
fyr21 + oyr31 fyr22 + oyr32 fyr23 + oyr33 fyTy + oyTz
r31 r32 r33 Tz
.
(1)
Let’s define m1 = (m11, m12, m13)
T
, m2 = (m21, m22, m23)
T
, m3 = (m31, m32, m33)
T
, m4 =
(m14, m24, m34)
T
. Also define r1 = (r11, r12, r13)
T
, r2 = (r21, r22, r23)
T
, r3 = (r31, r32, r33)
T
. Observe
that (r1, r2, r3) is the rotation matrix, then
(r1, r2, r3)
r
T
1
r
T
2
r
T
3
=
1 0 0
0 1 0
0 0 1
.
Then we have r
T
i
ri = 1, r
T
i
rj = 0 (i 6= j).
From M we have
mT
1 m3 = r31(fxr11 + oxr31) + r32(fxr12 + oxr32) + r33(fxr13 + oxr33)
= fx(r11r31 + r12r32 + r13r33) + ox(r
2
31 + r
2
32 + r
2
33)
= fx(r
T
1
r3) + ox(r
T
3
r3)
= ox
(2)
Similarly, Next, from M we have
mT
1 m1 = (fxr11 + oxr31)
2 + (fxr12 + oxr32)
2 + (fxr13 + oxr33)
2
= f
2
x
· r1
T
r1 + 2fxox · r1
T
r3 + o
2
x
· r3
T
r3 = f
2
x + o
2
x
(3)
So fx =
p
mT
1 m1 − o
2
x
. Similarly we have oy = mT
2 m3, fy =
q
mT
2 m2 − o
2
y
. Overall, we come to
the conclusion as follows
ox = mT
1 m3 oy = mT
2 m3 (4)
fx =
q
mT
1 m1 − o
2
x
fy =
q
mT
2 m2 − o
2
y
(5)
Preliminary.2.
Let XwYwZw be the world coordinate and xy be the image coordinate, we have the transformation
matrix M ∈ R
3×4
:
s
x
y
1
=
m11 m12 m13 m14
m21 m22 m23 m24
m31 m32 m33 m34
·
Xw
Yw
Zw
1
(6)
sx = m11Xw + m12Yw + m13Zw + m14,
sy = m21Xw + m22Yw + m23Zw + m24,
s = m31Xw + m32Yw + m33Zw + m34.
(7)
We can solve mij with the equation below:
X1
w Y
1
w Z
1
w 1 0 0 0 0 −x
1X1
w −x
1Y
1
w −x
1Z
1
w −x
1
0 0 0 0 X1
w Y
1
w Z
1
w 1 −y
1X1
w −y
1Y
1
w −y
1Z
1
w −y
1
.
.
.
.
.
.
Xn
w Y
n
w Z
n
w 1 0 0 0 0 −x
nXn
w −x
nY
n
w −x
nZ
n
w −x
n
0 0 0 0 Xn
w Y
n
w Z
n
w 1 −y
nXn
w −y
nY
n
w −y
nZ
n
w −y
n
·
m11
m12
m13
m14
m21
m22
m23
m24
m31
m32
m33
m34
= 0, (8)
where the first matrix is with size 2n × 12 (n is the number of available points).
Preliminary.3.
Solve the homogeneous linear equation Ax = 0, where x is the vector of N unknowns, and A is the
matrix of M × N coefficients. A quick observation is that there are infinite solutions for Ax = 0,
since we can randomly scale x with a scalar λ such that A(λx) = 0. Therefore, we assume kxk = 1.
Solving the equation can be converted to
min kAxk (9)
The minimization problem can be solved with Singular Value Decomposition (SVD). Assume that
A can be decomposed to UΣVT
, we have
min kAxk = kUΣVT xk = kΣVT xk. (10)
Note that kVT xk = kxk = 1, then let y = VT x, so we have
min kAxk = kΣyk
=
σ1
.
.
.
σn
0 · · · 0
.
.
.
.
.
.
.
.
.
0 · · · 0
y1
.
.
.
yn
,
(11)
where σ1 ≥ · · · ≥ σn ≥ 0. Recall that kyk = 1, we can set
y1
.
.
.
yn
=
0
.
.
.
1
. (12)
So x should be the last row of VT
.
Question
Figure 2 shows an image of the checkerboard, where XY Z is the world coordinate and xy is marked
as the image coordinate. The edge length of each grid on the checkerboard is 10mm in reality.
Suppose one pixel of the image is equivalent to 1mm. You can calculate the projection matrix from
world coordinate to image coordinate based on the 32 marked points on the checkerboard. From
the projection matrix you can get the intrinsic matrix which is indicated as
fx 0 ox
0 fy oy
0 0 1
(fx and
fy are not necessarily be the same).
• Design a program to obtain the intrinsic parameters fx, fy, ox, oy.
• If the original point of world coordinate changed, would the intrinsic parameters be the same?
In this task you are only allowed to use the library and library function already imported in the script “task2.py”.
Figure 2: Image of the checkerboard
Instructions:
• Compress the two python files, i.e., “task1.py”, “task2.py”, the given image (“checkerboard.png”)
into a zip file, name it as “UBID.zip” (replace “UBID” with your eight-digit UBID, e.g.,
51399256) and upload it to UBLearns before the due. The zip file you upload should not
contain files other than the three aforementioned files.
• Anyone whose code is evaluated as plagiarism, your grade will be 0 for this project.
• For all students whose code raise “RuntimeError”, your grade will be 0 for this task.
• Strictly follow the format in the scripts, i.e., “task1.py”, “task2.py”. Do Not modify the
code provided to you.
• Do Not import any library or APIs besides what has been listed. For task2, you are ONLY
allowed to use the library and library function already imported in the script.
• Late submissions within one day is allowed and will result in a 50% penalty. One day is
defined as 24 hours after the day/time the assignment is due (excluding weekends or school
holidays). After that, submissions will not be accepted.