Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
COMP 4102A: Assignment 3
Instructions for submission: Please write a document (pdf or doc) with your solutions on theory
questions. Put your code file and the output result in a zip folder including the answers of the
theory questions. Note that the total mark of this assignment is out of 130. You are expected to
work on the assignment individually.
1 Coding: Calibration (40 points)
The goal of this questions is to implement some code that performs calibration using the method
described in the class and in book(ch6.3); by first computing a projection matrix, and then de-
composing that matrix to find the extrinsic and intrinsic camera parameters. Use the approach
described in the slides. I have given you a program, written in C++ that uses OpenCV, called
projection-template.cpp. This program takes ten given 3d points and projects them into a 2d im-
age using the given supplied camera calibration matrix, rotation matrix and translation vector.
Your goal is to write the two routines that are missing, which are computeprojectionmatrix and
decomposeprojectionmatrix. The first routine computes the projection matrix using the method de-
scribed in Section 6.3.1 of the book, and the second uses the method in Section 6.3.2 to decompose
the projection matrix into a camera calibration matrix, rotation matrix and translation vector. It
should be the case that the computed camera matrix, rotation matrix and translation vector are
the same (or very similar) to the original versions that were used to create the projected points.
This shows that your two routines are working properly. A similar routine provided in Python
called projection-template-python.py. Submit your program source code and the resulting output
file assign3-out created by running this modified program. Or show a screen capture of the output
which shows that the computed quantities are the same, or close to the same as the original ones
used to create the projection matrix.
2 Theory questions(90 points)
1. Consider two points A and B in a simple stereo system. Point A projects to Al on the left
image, and Ar on the right image. Similarly there is a point B which projects to Bl and
Br. Consider the order of these two points in each image on their epipolar lines. There are
two possibilities; either they ordered on the epipolar lines in the same order; for example
they appear as Al, Bl and Ar, Br, or they are in opposite order, such as Bl, Al and Ar, Br.
Place the two 3d points A and B in two different locations in a simple stereo diagram which
demonstrates these two possibilities. (Draw a different picture for each situation).(20 points)
1
2. There is a simple stereo system with one camera placed above the other camera in the y
direction (not the x direction is as usual) by a distance of b. In such a case there is no
rotation between the cameras, only a translation by a vector T = [0, b, 0]. First compute the
essential matrix E in this case. You are given a point p1 in camera co-ordinates in the first
image as (x1, y1, f), and a matching point p2 in the second image where p2 is (x2, y2, f).
Write the equation of the epipolar line that contains the matching point p2 in camera co-
ordinates in the second image. In this case you are given p1 and you have computed E, and
you need to write the equation of the line that contains p2 (the free variables are x2, y2) using
p1 and the elements of E as the fixed variables. Now repeat the entire process again for the
case where T = [b, b, 0] (a translation of 45 degrees to the right in the x,y plane), and finally
where T = [0, 0, b] (a translation straight ahead in the Z direction). For the particular case
where p1= (0, 1, f) what is the equation of the epipolar line for all three situations? And
where p1= (1, 1, f) what is the equation of the epipolar line in these three situations? I want
these all equations simplified as far as possible, with all terms grouped and collected. Draw
the epipolar lines for all three cases; that is you need to draw the epipolar lines in the right
image for the two cases where p1 = (0, 1, f) and p1 = (1, 1, f). I want to have three different
diagrams where in each diagram you draw these two epipolar lines. Hint, in each of these
three situations where we move the second camera by a different translation vector so this
means that we will have three different equations, and three different diagrams.(30 points)
3. In simple stereo Z = f B/d. If the baseline B is 0.5 meter, Z is 2.0 meters, and f is 50
millimeters what is the value of d in mm? Repeat this process for Z = 1 meter, and 0.5 meter
to get two more values for d in mm (same f and B).
If we are measuring depth at a given value of Z then we have a certain accuracy in the
measurement which depends on how much error there is in computing the disparity. In turn,
the error in disparity computation depends on how accurately we can locate a feature, such
as a line or corner in the image. In practice, the error in computing the location of a feature
is fixed; it does not change regardless of the value of Z for that feature. Assume that this
error in disparity d for locating a feature is +− 1mm. In other words, for a computed value
of disparity d, the true value is d plus or minus 1mm. Now for each of the three given values
of d computed above, compute two new values for Z; Z high when d = d - 1 mm, and z low
when d = d + 1mm. Now in each of the three cases above compute the function Zdiff = Z
high - Z low. You will now have three values for Z diff. We call these three values Zdiff(2
meters), Zdiff(1 meter) and Zdiff(0.5meter). In these three cases we have cut the value of the
value of Z by one half, from 2 meters, to 1 meter to 0.5 meters. Hypothesize a relationship
that seems to hold (approximately) on the ratio of the Z diffs when we cut Z in half. Look at
the ratio of Zdiff(2 meters)/Zdiff(1 meter) and Zdiff(1 meter)/Zdiff(0.5 meter). If the number
these ratios are converging to is not obvious, then repeat the experiment again but compute
Zdiff(0.25meter) and consider the ratio which is Zdiff(0.5 meter)/Zdiff(0.25 meter). Guess the
obvious number! Another way to say this is to consider the following statements, where X is
that same number; If we are doing stereo measurements at a given distance Z we expect a
certain accuracy in the measurements (+−∆Z). If we now measure at one half the distance
of Z, which is Z/2 we expect our accuracy to improve by a factor of X. So when we cut our
depth in half, then depth resolution improves by a factor of X. Tell me the number X. You
also need to write down each of these ratios properly to get the full marks.(20 points)
2
4. In Figure 1 on the last page there are three cameras where the distance between the cameras
is B, and all three cameras have the same focal length f . The disparity dL = x0–xL, while
the disparity dR = xR–x0. Show that |dL| = |dR|. You should prove this relationship holds
mathematically by using the appropriate equations. This proof is trivial, but when you write
the proof you should use an English sentence to explain why these particular equations are
true. (20 points)