Geometry-based Methods in Vision

Assignment 2

Q1a:

Q1b:

Q2a:

Description:

1.1 Vanishing Point Calculation

1. Extract Annotated Parallel Lines: Read the coordinates of annotated parallel lines provided in the file data/q2/q2a.npy. Each pair of parallel lines corresponds to one vanishing point.

2. Calculate Vanishing Points: Vanishing points are determined by calculating the intersection of two lines. For each pair of parallel lines l1 and l2, the intersection (vanishing point) can be found using the following formula:

Vanishing Point = l1 × l2

where l1 and l2 are represented as line equations, and × denotes the cross product.

1.2 Estimation of the Camera Intrinsic Matrix

1. Principal Point Calculation: Given three orthogonal vanishing points vx, vy, vz, their relationship with the camera intrinsic matrix K is defined as follows:

vxT K-T K-1 vy = 0

vyT K-T K-1 vz = 0

vzT K-T K-1 vx = 0

Using these three orthogonality constraints, the camera intrinsic matrix K can be derived.

2. Solve for K: Under the assumption of zero skew and square pixels, the intrinsic matrix K has the following form:

K =   [ f   0   cx ]
     [ 0   f   cy ]
     [ 0   0   1 ]

where f is the focal length, and (cx, cy) are the principal point coordinates.

1.3 Implementation and Output

2. Derivation of Relevant Equations

1. Line Equations and Vanishing Point:

Given two line equations l1 = (a1, b1, c1) and l2 = (a2, b2, c2), the intersection (vanishing point) can be computed using the cross product:

v = l1 × l2 =
[ b1   c2 − c1   b2 ]
[ c1   a2 − a1   c2 ]
[ a1   b2 − b1   a2 ]

2. Orthogonality Relationship Between Vanishing Points:

The orthogonality relationship between vanishing points can be expressed as:

vxT w · vy = 0

where w = K-T K-1 is a transformation matrix related to the camera intrinsic matrix.

Q2b:

1. Image Annotation and Plane Extraction:

2. Homography Matrix Computation:

3. IAC Constraint Solving and Intrinsic Matrix Calculation:

4. Calculating Angles Between Planes:

5. Final Output:

The final output includes the calculated camera intrinsic matrix K and the computed angles between each pair of planes to verify the accuracy of the calibration.

Relevant Equations

Homography Matrix Constraints: For each plane, compute the constraint matrix:
IAC · h1 · h2 = 0
where h1 and h2 are the first and second columns of the homography matrix H.
Angle Calculation: The angle between two homogeneous plane equations ni, nj is given by:
cos θ = (niT · K-1 · K-T · T · nj) / (||niT · K-1|| ||njT · K-1||)
This formula calculates the angle between the normal vectors of the two planes using the intrinsic matrix.

Q3a:

Description:

1. Camera Projection Model and Intrinsic Matrix

In single view geometry, all 2D image coordinates are obtained through the projection of 3D spatial points. The projection model is usually expressed in the homogeneous coordinate form:

s · x = K · [R | t] · X

where:

          K = | fx  0   cx |
              | 0    fy  cy |
              | 0     0     1 |
        

where fx, fy are the focal lengths in the horizontal and vertical directions, and cx, cy are the coordinates of the principal point (the intersection of the optical axis and image plane).

2. Vanishing Points and Linear Constraints

Parallel lines in the real world will converge at a point in the image, called a vanishing point. The vanishing point is computed based on the intersection of line equations. Given two line equations:

l1 = (a1, b1, c1)    and    l2 = (a2, b2, c2)

The intersection can be computed using:

v = l1 × l2

where × denotes the cross product.

3. Ray-Plane Intersection

For each pixel in the image, the corresponding spatial ray direction can be derived using the inverse of the intrinsic matrix:

r = K-1 · x

where r is the direction vector of the ray, and x is the pixel coordinate in the image plane.

4. Plane Equation and Normal Vector Calculation

If multiple points on a plane in the image are known, the plane equation can be derived. Given three non-collinear points (P1, P2, P3), the normal vector n can be calculated using the cross product:

n = (P2 − P1) × (P3 − P1)

5. Color Mapping and 3D Point Cloud Generation

Each 3D point can be assigned a color value based on its corresponding 2D pixel in the image. For a point in the image at (x, y), the color value C is given by:

C = I(y, x)

6. View Transformation and 3D Visualization

Once the 3D point cloud is generated, different view transformations can be applied to visualize the 3D structure from various angles. A view transformation typically uses a rotation matrix or a view transformation matrix to change the observation perspective:

          V = | R  t |
              | 0  1 |
        

where R is a rotation matrix and t is a translation vector. By applying V to the 3D point cloud, different views of the 3D image can be obtained.