Nodes/comfyui_cv/CV Decompose Projection Matrix (RQ)
ComfyUI Node

CV Decompose Projection Matrix (RQ)

Splits a camera/projection matrix with cv2.RQDecomp3x3. This is the compact RQ decomposition used to recover a K-like upper-triangular matrix and an orthogonal rotation from M = R @ Q, while also exposing the per-axis rotation matrices OpenCV computes. A full 3x4 projection matrix P = K[R|t] is accepted directly: its left 3x3 block (K @ R) is what gets decomposed, so R is the intrinsics and Q the camera rotation. The translation is NOT recovered - use 'Solve PnP' / 'Pose To Matrix' for that.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Decompose Projection Matrix (RQ)
  • matrix
  • matrix
  • Q
  • R
  • Qx
  • Qy
  • Qz
Categoryimage/CV/features

Inputs (1)

NameTypeDefaultDescription
matrixNPARRAYMatrix to decompose: either a 3x3 matrix, or a full 3x4 camera projection matrix P = K[R|t] (only its left 3x3 block is decomposed; the translation column is ignored).

Outputs (6)

NameTypeDescription
matrixNPARRAYThe 3x3 block that was actually decomposed, as float64 (the input itself for a 3x3 matrix, its left 3x3 block for a 3x4 one). R @ Q reconstructs exactly this - handy for matrix comparisons and inspectors.
QNPARRAY3x3 orthogonal matrix from the RQ decomposition.
RNPARRAY3x3 upper-triangular matrix from the RQ decomposition (K-like for camera matrices).
QxNPARRAYOpenCV's x-axis rotation matrix component. NOTE the composition order: OpenCV reduces M by RIGHT-multiplying these, so Qx @ Qy @ Qz is Q TRANSPOSED - the identity that holds is Q = Qz.T @ Qy.T @ Qx.T (exactly, and M = R @ Qz.T @ Qy.T @ Qx.T).
QyNPARRAYOpenCV's y-axis rotation matrix component. Composes as Q = Qz.T @ Qy.T @ Qx.T, not Qx @ Qy @ Qz (see Qx).
QzNPARRAYOpenCV's z-axis rotation matrix component. Composes as Q = Qz.T @ Qy.T @ Qx.T, not Qx @ Qy @ Qz (see Qx).