Home Syllabus Schedule AI Prompt Resources

Homework 1 Solutions

CSSE 461 - Computer Vision

Problem 1: Pinhole Camera Model

Part a. Using the pinhole projection equations:

\[x' = f \frac{X}{Z} = 50 \cdot \frac{100}{500} = 10 \text{ mm}\]

\[y' = f \frac{Y}{Z} = 50 \cdot \frac{50}{500} = 5 \text{ mm}\]

The point projects to \((x', y') = (10, 5)\) mm on the image plane.

Part b. For point \(\mathbf{Q} = (200, 100, 1000)\) mm:

\[x' = f \frac{X}{Z} = 50 \cdot \frac{200}{1000} = 10 \text{ mm}\]

\[y' = f \frac{Y}{Z} = 50 \cdot \frac{100}{1000} = 5 \text{ mm}\]

The point also projects to \((x', y') = (10, 5)\) mm.

Part c. Point \(\mathbf{Q}\) is exactly twice as far from the camera as \(\mathbf{P}\) in all three coordinates (i.e., \(\mathbf{Q} = 2\mathbf{P}\)). They lie on the same ray from the camera center. Since the projection equations divide each coordinate by depth \(Z\), the scaling factor cancels out and both points project to the same location.

Problem 2: Homogeneous Coordinates

Part a. In homogeneous coordinates with \(w = 1\):

\[\mathbf{p}_h = \begin{pmatrix} 3 \\ 4 \\ 1 \end{pmatrix}\]

Part b. Two other valid representations (any non-zero scale factor works):

\[\mathbf{p}_h = \begin{pmatrix} 6 \\ 8 \\ 2 \end{pmatrix} \quad \text{or} \quad \mathbf{p}_h = \begin{pmatrix} 1.5 \\ 2 \\ 0.5 \end{pmatrix}\]

Part c. A homogeneous point representing a point at infinity has \(w = 0\). For example:

\[\mathbf{p}_\infty = \begin{pmatrix} 1 \\ 0 \\ 0 \end{pmatrix}\]

represents a point at infinity in the positive x-direction in the 2D Euclidean plane.

Problem 3: Camera Calibration Matrix

Part a. The camera calibration matrix is:

\[\mathbf{K} = \begin{pmatrix} f_x & 0 & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \end{pmatrix} = \begin{pmatrix} 800 & 0 & 320 \\ 0 & 800 & 240 \\ 0 & 0 & 1 \end{pmatrix}\]

Part b. First, write the point in homogeneous coordinates:

\[\mathbf{P}_c = \begin{pmatrix} 2 \\ -1 \\ 5 \end{pmatrix}\]

Apply the calibration matrix:

\[\mathbf{p}_h = \mathbf{K} \mathbf{P}_c = \begin{pmatrix} 800 & 0 & 320 \\ 0 & 800 & 240 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} 2 \\ -1 \\ 5 \end{pmatrix} = \begin{pmatrix} 800(2) + 320(5) \\ 800(-1) + 240(5) \\ 5 \end{pmatrix} = \begin{pmatrix} 3200 \\ 400 \\ 5 \end{pmatrix}\]

Convert from homogeneous to Euclidean coordinates by dividing by the third component:

\[u = \frac{3200}{5} = 640 \text{ pixels}\]

\[v = \frac{400}{5} = 80 \text{ pixels}\]

The point appears at pixel coordinates \((640, 80)\).

Problem 4: Extrinsic Parameters

Part a. We need a rotation that makes the camera look along world +X instead of world +Z. This means: - World +X should map to camera +Z (forward) - World +Y should map to camera +Y (down) - World +Z should map to camera -X (left)

The rotation matrix is:

\[\mathbf{R} = \begin{pmatrix} 0 & 0 & -1 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end{pmatrix}\]

Part b.

We know the location of the camera center in both camera and world coordinates. Substitute these into \(\mathbf{P}_c = \mathbf{R} \mathbf{P}_w + \mathbf{t}\):

\[\begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 & 0 & -1 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end{pmatrix} \begin{pmatrix} 10 \\ 0 \\ 0 \end{pmatrix} + \mathbf{t} \]

Now solve for \(\mathbf{t}\). The translation vector (representing the origin of the world coordinate system, expressed in camera coordinates), is

\[\mathbf{t} = \begin{pmatrix} 0 \\ 0 \\ -10 \end{pmatrix}\]

Part c. Convert the world point \((20, 0, 0)\) to camera coordinates:

\[\mathbf{P}_c = \begin{pmatrix} 0 & 0 & -1 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end{pmatrix} \begin{pmatrix} 20 \\ 0 \\ 0 \end{pmatrix} + \begin{pmatrix} 0 \\ 0 \\ -10 \end{pmatrix} \]

The point is at \(\mathbf{P}_c = (0, 0, 10)\) meters in camera coordinates (10 meters directly in front of the camera).

Problem 5: Triangulation

Part a. There should be a diagram showing camera 1 at the origin and camera two at \((1,0,0)\). Both cameras face the same direction, towards +z. There is a 3D point between and in front of both cameras.

Part b. For camera 1:

\[x'_1 = f \frac{X}{Z}\]

Part c. For camera 2, the point has x-coordinate \((X - b)\) in camera 2’s frame:

\[x'_2 = f \frac{X - b}{Z}\]

Part d. From part (b): \(X = \frac{x'_1 Z}{f}\)

Substitute into part (c):

\[x'_2 = f \frac{X - b}{Z} = x'_1 - \frac{bf}{Z}\]

Solve for \(Z\):

\[Z = \frac{bf}{x'_1 - x'_2}\]

With \(b = 1\) m, \(f = 0.01\) m, \(x'_1 = 0.007\) m, \(x'_2 = -0.010\) m:

\[Z = \frac{(1)(0.01)}{0.007 - (-0.010)} = \frac{0.01}{0.017} \approx 0.588 \text{ m}\]

Then:

\[X = \frac{x'_1 Z}{f} = \frac{(0.007)(0.588)}{0.01} \approx 0.412 \text{ m}\]

Answer: \(X \approx 0.412\) m, \(Z \approx 0.588\) m