machinevisiontoolbox.Camera.CentralCamera.decomposeH

CentralCamera.decomposeH(H, K=None)[source]

Decompose homography matrix

Parameters:
  • H (ndarray(3,3)) – homography matrix

  • K (ndarray(3,3), optional) – camera intrinsics, defaults to parameters from object

Returns:

camera poses, plane normals

Return type:

SE3, list of ndarray(3,1)

Decomposes the homography matrix into the camera motion and the normal to the plane. In practice, there are multiple solutions. The translation not to scale.

Example:

>>> from machinevisiontoolbox import CentralCamera, mkgrid
>>> from spatialmath import SE3
>>> camera1 = CentralCamera(name="camera 1", f=0.002, imagesize=1000, rho=10e-6, pose=SE3.Tx(-0.1)*SE3.Ry(0.4))
>>> camera2 = CentralCamera(name="camera 2", f=0.002, imagesize=1000, rho=10e-6, pose=SE3.Tx(0.1)*SE3.Ry(-0.4))
>>> T_grid = SE3.Tz(1) * SE3.Rx(0.1) * SE3.Ry(0.2)
>>> P = mkgrid(3, 1.0, pose=T_grid)
>>> p1 = camera1.project_point(P)
>>> p2 = camera2.project_point(P);
>>> H, resid = CentralCamera.points2H(p1, p2)
>>> T, normals = camera1.decomposeH(H)
>>> T.printline(orient="camera")
t = -0.185, 0, -0.0783; rpy/yxz = -8.39e-06°, 4.61e-06°, -45.8°
t = 0.185, 0, 0.0783; rpy/yxz = -8.39e-06°, 4.61e-06°, -45.8°
t = 0.0197, 0.0192, -0.199; rpy/yxz = 1.09°, 0.338°, -34.4°
t = -0.0197, -0.0192, 0.199; rpy/yxz = 1.09°, 0.338°, -34.4°
>>> normals
(array([[ 0.1968],
       [ 0.0978],
       [-0.9756]]), array([[-0.1968],
       [-0.0978],
       [ 0.9756]]), array([[-0.9552],
       [-0.01  ],
       [-0.2958]]), array([[0.9552],
       [0.01  ],
       [0.2958]]))
Reference:
  • Robotics, Vision & Control for Python, Section 14.2.4, P. Corke, Springer 2023.

Seealso:

points2H H opencv.decomposeHomographyMat