Class CompatibleProjectiveHomography
projection of world point 'X' to pixel 'x': x = P*X
Two projective frames of the same view are related by 4x4 homography H. 3D points are related too by H
P1[i]*H = P2[i]
X1 = H*X2
P is a 3x4 camera matrix and has a projective ambiguity. x = P*inv(H)*H*X, P' = P*inv(H) and X' = H*X
- Fitzgibbon, Andrew W., and Andrew Zisserman. "Automatic camera recovery for closed or open image sequences." European conference on computer vision. Springer, Berlin, Heidelberg, 1998.
- P. Abeles, "BoofCV Technical Report: Automatic Camera Calibration" 2020-1
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
fitCameraPoints
(DMatrixRMaj camera1, DMatrixRMaj camera2, List<Point4D_F64> points1, List<Point4D_F64> points2, DMatrixRMaj H) Solves for the transform H using one view and 2 or more points.boolean
fitCameras
(List<DMatrixRMaj> cameras1, List<DMatrixRMaj> cameras2, DMatrixRMaj H) Computes homography which relate common projective camera transforms to each other by solving a linear system.boolean
fitPoints
(List<Point4D_F64> points1, List<Point4D_F64> points2, DMatrixRMaj H) Finds the homography H by by minimizing algebriac error.void
refineReprojection
(List<DMatrixRMaj> cameras1, List<Point4D_F64> scene1, List<Point4D_F64> scene2, DMatrixRMaj H) void
refineWorld
(List<Point3D_F64> scene1, List<Point3D_F64> scene2, DMatrixRMaj H) Refines the initial estimate of H by reducing the Euclidean distance between points.
-
Field Details
-
solver
-
nullspace
-
solvePInv
-
lm
-
configConverge
-
-
Constructor Details
-
CompatibleProjectiveHomography
public CompatibleProjectiveHomography()
-
-
Method Details
-
fitPoints
Finds the homography H by by minimizing algebriac error. Modified version of algorithm described in [1]. See [2] for implementation details. Solution is found by finding the null space. A minimum of 5 points are required to solve the 15 degrees of freedom in H.X1 = H*X2
NOTE: Fails when all points lie exactly on the same plane
- Parameters:
points1
- Set of points from view A but in projective 1. Recommended that they have f-norm of 1points2
- Set of points from view A but in projective 2. Recommended that they have f-norm of 1H
- (Output) 4x4 homography relating the views. P1*H = P2, X1 = H*X2- Returns:
- true if successful or false if it fails
-
fitCameras
Computes homography which relate common projective camera transforms to each other by solving a linear system. A Direct Linear Transform is used due to scale ambiguity. Non-linear refinement is recommended, before bundle adjustment. Two or more camera matrices are required.P1[i] = P2[i]*inv(H)
NOTE: This will work with planar scenes
- Parameters:
cameras1
- list of camera matricescameras2
- list of camera matrices, same views as camera1H
- (Output) 4x4 homography relating the views. P1*H = P2, X1 = H*X2- Returns:
- true if successful or false if it failed
-
fitCameraPoints
public boolean fitCameraPoints(DMatrixRMaj camera1, DMatrixRMaj camera2, List<Point4D_F64> points1, List<Point4D_F64> points2, DMatrixRMaj H) Solves for the transform H using one view and 2 or more points. The two camera matrices associated with the same view constrain 11 out of the 15 DOF. Each points provides another 3 linear constraints.H(v) = pinv(P)*P' + hvT
where 'h' is null-space of P. 'v' is 4-vector and is unknown, solved with linear equation
NOTE: While 2 is the minimum number of views during testing it seemed to require 4 points with perfect data. The math was double checked and no fundamental flaw could be found in the test. More investigation is needed. There is a large difference in scales that could be contributing to this problem.
NOTE: Produces poor results when the scene is planar
- Parameters:
camera1
- Camera matrixcamera2
- Camera matrix of the same view but another projective spacepoints1
- Observations from camera1points2
- Observations from camera2H
- (Output) 4x4 homography relating the views. P1*H = P2, X1 = H*X2- Returns:
- true if successful
-
refineWorld
Refines the initial estimate of H by reducing the Euclidean distance between points.NOTE: parameterization can be improved. Optimizes 16-DOF when only 15 is needed. scale isn't bounded
- Parameters:
scene1
- List of points in world coordinatesscene2
- List of points in world coordinates, but at a different projective frameH
- (Output) 4x4 homography that related to two sets of camera matrices. P1*H = P2
-
refineReprojection
public void refineReprojection(List<DMatrixRMaj> cameras1, List<Point4D_F64> scene1, List<Point4D_F64> scene2, DMatrixRMaj H)
-