Skip to content

decomposeHomographyMat

geometryfunctionOpenCV 5.0.0
import { decomposeHomographyMat } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSH, K, rotations, translations
FUNCTIONdecomposeHomographyMat
RETURN TYPEnumber
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

example: samples/cpp/tutorial_code/features/Homography/decompose_homography.cpp An example program with homography decomposition.

Check tutorial_homography "the corresponding tutorial" for more details. Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).

decomposeHomographyMat(H: Mat, K: Mat, rotations: MatVector, translations: MatVector, normals: MatVector): number;
H

The input homography matrix between two images.

K

The input camera intrinsic matrix.

rotations

Output destination, filled by the native operation. Array of rotation matrices.

translations

Output destination, filled by the native operation. Array of translation matrices.

normals

Output destination, filled by the native operation. Array of plane normal matrices.

This function extracts relative camera motion between two views of a planar object and returns up to four mathematical solution tuples of rotation, translation, and plane normal. The decomposition of the homography matrix H is described in detail in [Malis2007].

If the homography H, induced by the plane, gives the constraint

s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}

on the source image points p_i and the destination image points p'_i, then the tuple of rotations[k] and translations[k] is a change of basis from the source camera's coordinate system to the destination camera's coordinate system. However, by decomposing H, one can only get the translation normalized by the (typically unknown) depth of the scene, i.e. its direction but with normalized length.

If point correspondences are available, at least two solutions may further be invalidated, by applying positive depth constraint, i.e. all points must be in front of the camera.

Returns

The number result.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.