decomposeHomographyMat
import { decomposeHomographyMat } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
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;HThe input homography matrix between two images.
KThe input camera intrinsic matrix.
rotationsOutput destination, filled by the native operation. Array of rotation matrices.
translationsOutput destination, filled by the native operation. Array of translation matrices.
normalsOutput 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_iand the destination image pointsp'_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.
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.