Projection Matrix:
[[ 6.12468612e-01, -2.80769806e-01, 1.09185025e-01, 2.12092927e-01],
[-8.90197009e-02, -6.43243106e-01, 1.93261536e-01, 1.73520830e-01],
[ 5.51654830e-05, -1.35588807e-04, -7.00171505e-05, 9.52266452e-05]]
Intrinsic Matrix:
[[ 1.15417802e+03, 0.00000000e+00, 5.75066005e+02],
[ 0.00000000e+00, 1.15417802e+03, 4.31939090e+02],
[ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]]
First we obtain the vanishing points. For obtaining the omega (IAC) matrix under the assumption that camera has zero skew, and that the pixels are square, we require atleast a 3 constraints
Procedure:
1. First we compute the vanishing points from pairs of parallel lines.
2. Formulate matrix A using vanishing points similar to the formulation in metric rectification.
3. Perform SVD on matrix A to find the omega matrix (IAC).
4. Assume that the camera has zero skew, and that the pixels are square.
5. Therefore, w11 = w22 and w12 = w21 = 0.
6. Use Cholesky decomposition to compute the intrinsic matrix K.
7. Normalize the intrinsic matrix with the last element (3,3)
8. Visualize vanishing points and principal point on the image.
Key equations:
1. W matrix for the assumed camera matrix can be represented as, w = [w1, 0, w2; 0, w1, w3; w2, w3, w4]
2. If l1 is a vanishing point1 and l2 is the vanishing point 2, then l1.T @ w @ l2 = 0
3. Stacking all the three constraints, we get A @ w_flat = 0
where w_flat = [w1, w2, w3, w4].
4. Each row of A will be [l1[0]*l2[0] + l1[1]*l2[1], l1[0]*l2[2] + l1[2]*l2[0], l1[1]*l2[2] + l1[2]*l2[1], l1[2]*l2[2]]. Stack up all the rows to get A.
5. SVD of A will provide w_flat = [w1, w2, w3, w4] which forms the w (IAC) matrix.
6. W = L @ L.T where L is the Cholesky decomposition of W.
7. Intrinsic matrix K = inv(L.T)
Intrinsic Matrix:
[[ 1.08447642e+03, -1.35121131e+01, 5.20013594e+02],
[ 0.00000000e+00, 1.07900526e+03, 4.02544642e+02],
[ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]]
Angles between the planes (degrees):
Plane 1 and Plane 2 : 67.58 degrees
Plane 2 and Plane 3 : 94.78 degrees
Plane 1 and Plane 3 : 92.25 degrees
Intrinsic Matrix:
[[1.13215411e+03, 6.87406575e+01, 5.47312078e+02],
[0.00000000e+00, 1.02411710e+03, 6.86235324e+02],
[0.00000000e+00, 0.00000000e+00, 1.00000000e+00]]
Angles between the planes (degrees):
Plane 1 and Plane 2 : 81.29 degrees
Plane 2 and Plane 3 : 79.52 degrees
Plane 1 and Plane 3 : 87.63 degrees
For computing the homography between two images, we need a minimum of 4 correspondences.
Procedure:
1. Use the three perpendicular set of parallel lines from the first two planes to obtain the intrinsic matrix K.
2. From the annotations of the planes, obtain the pixel points which lie inside the planes.
3. Assume the world coordinates of the 2nd corner of the first plane to be situated at a unit distance.
4. Estimate the 3D world coordinates of the reference base point using intrinsic matrix, pixel coordinates and the unit distance assumption.
5. We need to compute the normal direction of the plane in world. For this obtain the vanishing points of the two set of parallel lines.
6. Obtain the directions of the plane edges using the intrinsic matrix and the vanishing points. Get plane normal from these directions.
7. Obtain the constant offset in the plane equation by substituting the world coordinates of the reference base point in the plane equation.
8. Cast rays for each pixel inside the plane and find its intersection with the plane. Assign the color of the pixel to the 3D world point
9. Repeat the same for all the planes.
Key equations:
1. Plane equation: n.T @ X + a = 0
2. Dir of line with vanishing point v = inv(K) @ v
3. Normal of the plane with vanishing points v1, v2 = cross(inv(K) @ v1, inv(K) @ v2)
4. Ray passing through the pixel p = inv(K) @ p