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. 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.
get_K()
is used to estimate the camera intrinsic matrix K
based on the vanishing points.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 ]
The orthogonality relationship between vanishing points can be expressed as:
where w = K-T K-1
is a transformation matrix related to the camera intrinsic matrix.
data/q2b.png
is read, and the annotation file data/q2/q2b.npy
containing three plane annotations (square regions) is loaded.annotate_planes
function is used to load the annotated points and convert them into plane contours. Each plane is represented by its corner points and is visualized for verification.get_H
, the algorithm computes the homography matrix H
for each plane. This matrix describes the geometric transformation between the plane and the image, and it is a crucial element for calculating the camera intrinsics.H
, the function get_IAC_constraint
generates constraints for the Image of the Absolute Conic (IAC) matrix. The IAC matrix characterizes the geometric properties of all planes in the image and is used to determine the camera intrinsics.3 x 3
form, which encodes the geometric constraints for the camera.validate_H_constraints
is used to verify if the homography matrices satisfy the constraints imposed by the IAC matrix, ensuring that the obtained IAC is correct.calculate_intrinsic_matrix
, the intrinsic matrix K
is calculated from the IAC matrix using Cholesky Decomposition. This matrix is normalized so that the bottom-right element is 1.compute_plane_angles
, the algorithm calculates the angles between each pair of planes, using the intrinsic matrix K
.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.
IAC · h1 · h2 = 0
h1
and h2
are the first and second columns of the homography matrix H
.
ni, nj
is given by:
cos θ = (niT · K-1 · K-T · T · nj) / (||niT · K-1|| ||njT · K-1||)