$30
Perspective Projections Project
Consider an image P(X, Y ) that lies on the following 3D plane:
Z = aX + bY + c, (1)
The perspective projection of P(X, Y ) is the image Q(u, v). In this project you are asked to compute Q
from P, the camera calibration parameters f, u0, v0, and the plane parameters a, b, c. It can be shown that
the inverse transformation is given by the following equations:
X =
c(u − u0)
f − a(u − u0) − b(v − v0)
=
cx
f − ax − by , Y =
c(v − v0)
f − a(u − u0) − b(v − v0)
=
cy
f − ax − by . (2)
Part I
Write a program (OpenCV, python) that gets as input P, f, u0, v0, and a, b, c from the command line and
displays Q. It should be executed as follows:
python3 mynetid1.py image f u0 v0 a b c
The geometric transformation should be implemented with the OpenCV routine “warpPerspective”. Out of
range values should be of “0” value, and the interpolation should be bilinear.
(Figuring out how to use “warpPerspective” with these argument is part of the project requirements.)
Part II
Write a program (OpenCV, python) that gets as input the image P and c from the command line. (All other
arguments are hard coded.) It displays two images as described later. It should be executed as follows:
python3 mynetid2.py image c
The two images to be displayed are defined as follows:
1. The value of Z at the image center is c. The vertical line that passes through the image center is
viewed as a vertical line. The left side of the image has a smaller Z value than the right side.
2. The value of Z at the image center is c. The horizontal line that passes through the image center is
viewed as a horizontal line. The bottom side of the image has a smaller Z value than the top side.
The perspective projection distortion should be big enough to be observed in the displayed images.
What you need to submit
• A document describing the how the parameters of warpPerspective were calculated in parts I and II.
• The python scripts mynetid1.py and mynetid2.py.
Due Date: TBA
1