Operator Reference

hom_mat3d_projectT_hom_mat3d_projectHomMat3dProjectHomMat3dProjecthom_mat3d_project (Operator)

hom_mat3d_projectT_hom_mat3d_projectHomMat3dProjectHomMat3dProjecthom_mat3d_project — Project an affine 3D transformation matrix to a 2D projective transformation matrix.

Signature

Herror T_hom_mat3d_project(const Htuple HomMat3D, const Htuple PrincipalPointRow, const Htuple PrincipalPointCol, const Htuple Focus, Htuple* HomMat2D)

void HomMat3dProject(const HTuple& HomMat3D, const HTuple& PrincipalPointRow, const HTuple& PrincipalPointCol, const HTuple& Focus, HTuple* HomMat2D)

HHomMat2D HHomMat3D::HomMat3dProject(const HTuple& PrincipalPointRow, const HTuple& PrincipalPointCol, const HTuple& Focus) const

HHomMat2D HHomMat3D::HomMat3dProject(double PrincipalPointRow, double PrincipalPointCol, double Focus) const

def hom_mat3d_project(hom_mat_3d: Sequence[float], principal_point_row: Union[float, int], principal_point_col: Union[float, int], focus: Union[float, int]) -> Sequence[float]

Description

hom_mat3d_projecthom_mat3d_projectHomMat3dProjectHomMat3dProjecthom_mat3d_project calculates a homogeneous projection matrix from a homogeneous 3x4 transformation matrix describing an affine transformation in 3D. The result can be used to project a plane, in particular a plane containing an image. The projection matrix defines a projective transformation between two (two-dimensional) planes.

This can be used to create perspective distortions, which occur in a projection of a plane rotated around an axis other than the z axis. Usually, however, projective transformations are determined from point correspondences (see vector_to_proj_hom_mat2dvector_to_proj_hom_mat2dVectorToProjHomMat2dVectorToProjHomMat2dvector_to_proj_hom_mat2d, hom_vector_to_proj_hom_mat2dhom_vector_to_proj_hom_mat2dHomVectorToProjHomMat2dHomVectorToProjHomMat2dhom_vector_to_proj_hom_mat2d, and proj_match_points_ransacproj_match_points_ransacProjMatchPointsRansacProjMatchPointsRansacproj_match_points_ransac).

Matrices for rotation, scale, and translation can be constructed using the operators hom_mat3d_identityhom_mat3d_identityHomMat3dIdentityHomMat3dIdentityhom_mat3d_identity, hom_mat3d_scalehom_mat3d_scaleHomMat3dScaleHomMat3dScalehom_mat3d_scale, hom_mat3d_rotatehom_mat3d_rotateHomMat3dRotateHomMat3dRotatehom_mat3d_rotate, hom_mat3d_translatehom_mat3d_translateHomMat3dTranslateHomMat3dTranslatehom_mat3d_translate and pose_to_hom_mat3dpose_to_hom_mat3dPoseToHomMat3dPoseToHomMat3dpose_to_hom_mat3d.

Note that for 3D transformations the x-axis represents the column axis while the y-axis represents the row axis (see also Calibration) while in projective_trans_imageprojective_trans_imageProjectiveTransImageProjectiveTransImageprojective_trans_image, the first row of HomMat2DHomMat2DHomMat2DhomMat2Dhom_mat_2d contains the transformation of the row axis and the second row contains the transformation of the column axis of the image.

The point (PrincipalPointRowPrincipalPointRowPrincipalPointRowprincipalPointRowprincipal_point_row, PrincipalPointColPrincipalPointColPrincipalPointColprincipalPointColprincipal_point_col) is the principal point of the projection and the point (PrincipalPointRowPrincipalPointRowPrincipalPointRowprincipalPointRowprincipal_point_row, PrincipalPointColPrincipalPointColPrincipalPointColprincipalPointColprincipal_point_col, 0) can thus be interpreted as the position of the camera in a virtual three-dimensional space. The direction of view is along the positive z-axis.

In this virtual space the plane containing the input image as well as the image plane are located at z=FocusFocusFocusfocusfocus, which is FocusFocusFocusfocusfocus pixels away form the camera. As a result, using the identity matrix as the input matrix HomMat3DHomMat3DHomMat3DhomMat3Dhom_mat_3d leads to a matrix HomMat2DHomMat2DHomMat2DhomMat2Dhom_mat_2d which also represents the identity in 2D.

Consequently, the parameter FocusFocusFocusfocusfocus is the “focal distance” of the virtual camera used and its unit is pixels. Its value influences the degree of perspective distortions. The same input matrix at a bigger focal distance results in weaker distortions than at a low focal distance.

Let H be the affine 3D matrix with elements , (r,c)=(PrincipalPointRowPrincipalPointRowPrincipalPointRowprincipalPointRowprincipal_point_row,PrincipalPointColPrincipalPointColPrincipalPointColprincipalPointColprincipal_point_col) and f=FocusFocusFocusfocusfocus.

Then the projective transformation matrix is calculated as follows: First, a 3x4 projection matrix is calculated as:

Since the image of a plane containing points (x, y, f, 1)^T is to be calculated the last two columns of Q can be joined:

Finally, the columns and rows of R are swapped in a way that the first row of P contains the transformation of the row coordinates and the second row contains the transformation of the column coordinates so that P can be used directly in projective_trans_imageprojective_trans_imageProjectiveTransImageProjectiveTransImageprojective_trans_image:

The overall transformation can be written as:

Execution Information

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).
  • Multithreading scope: global (may be called from any thread).
  • Processed without parallelization.

Parameters

HomMat3DHomMat3DHomMat3DhomMat3Dhom_mat_3d (input_control)  hom_mat3d HHomMat3D, HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

3×4 3D transformation matrix.

PrincipalPointRowPrincipalPointRowPrincipalPointRowprincipalPointRowprincipal_point_row (input_control)  point.y HTupleUnion[float, int]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Row coordinate of the principal point.

Default: 256

Suggested values: 16, 32, 64, 128, 240, 256, 512

PrincipalPointColPrincipalPointColPrincipalPointColprincipalPointColprincipal_point_col (input_control)  point.x HTupleUnion[float, int]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Column coordinate of the principal point.

Default: 256

Suggested values: 16, 32, 64, 128, 256, 320, 512

FocusFocusFocusfocusfocus (input_control)  number HTupleUnion[float, int]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Focal length in pixels.

Default: 256

Suggested values: 1, 2, 5, 256, 32768

HomMat2DHomMat2DHomMat2DhomMat2Dhom_mat_2d (output_control)  hom_mat2d HHomMat2D, HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

Homogeneous projective transformation matrix.

Possible Predecessors

hom_mat3d_identityhom_mat3d_identityHomMat3dIdentityHomMat3dIdentityhom_mat3d_identity, hom_mat3d_rotatehom_mat3d_rotateHomMat3dRotateHomMat3dRotatehom_mat3d_rotate, hom_mat3d_translatehom_mat3d_translateHomMat3dTranslateHomMat3dTranslatehom_mat3d_translate, hom_mat3d_scalehom_mat3d_scaleHomMat3dScaleHomMat3dScalehom_mat3d_scale

Possible Successors

projective_trans_imageprojective_trans_imageProjectiveTransImageProjectiveTransImageprojective_trans_image, projective_trans_point_2dprojective_trans_point_2dProjectiveTransPoint2dProjectiveTransPoint2dprojective_trans_point_2d, projective_trans_regionprojective_trans_regionProjectiveTransRegionProjectiveTransRegionprojective_trans_region, projective_trans_contour_xldprojective_trans_contour_xldProjectiveTransContourXldProjectiveTransContourXldprojective_trans_contour_xld, hom_mat2d_inverthom_mat2d_invertHomMat2dInvertHomMat2dInverthom_mat2d_invert

Module

Foundation