Class CompatibleProjectiveHomography


public class CompatibleProjectiveHomography extends Object
Algorithms for finding a 4x4 homography which can convert two camera matrices of the same view but differ in only the projective ambiguity. This is needed if extending a projective scene by independently computing the solution set sets of 2, 3 or more views. This provides a mechanism "stitching" the solutions together using their common views.

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

  1. Fitzgibbon, Andrew W., and Andrew Zisserman. "Automatic camera recovery for closed or open image sequences." European conference on computer vision. Springer, Berlin, Heidelberg, 1998.
  2. P. Abeles, "BoofCV Technical Report: Automatic Camera Calibration" 2020-1
  • Field Details

  • Constructor Details

    • CompatibleProjectiveHomography

      public CompatibleProjectiveHomography()
  • Method Details

    • fitPoints

      public boolean fitPoints(List<Point4D_F64> points1, List<Point4D_F64> points2, DMatrixRMaj H)
      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

      points1 - Set of points from view A but in projective 1. Recommended that they have f-norm of 1
      points2 - Set of points from view A but in projective 2. Recommended that they have f-norm of 1
      H - (Output) 4x4 homography relating the views. P1*H = P2, X1 = H*X2
      true if successful or false if it fails
    • fitCameras

      public 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. 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

      cameras1 - list of camera matrices
      cameras2 - list of camera matrices, same views as camera1
      H - (Output) 4x4 homography relating the views. P1*H = P2, X1 = H*X2
      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

      camera1 - Camera matrix
      camera2 - Camera matrix of the same view but another projective space
      points1 - Observations from camera1
      points2 - Observations from camera2
      H - (Output) 4x4 homography relating the views. P1*H = P2, X1 = H*X2
      true if successful
    • refineWorld

      public 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.

      NOTE: parameterization can be improved. Optimizes 16-DOF when only 15 is needed. scale isn't bounded

      scene1 - List of points in world coordinates
      scene2 - List of points in world coordinates, but at a different projective frame
      H - (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)