Nodes/opencv-comfyui/OpenCV RQDecomp3x3_0
ComfyUI Node

OpenCV RQDecomp3x3_0

Split a camera matrix into rotation and shear

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV RQDecomp3x3_0
  • src
  • mtxR
  • mtxQ
  • Qx
  • Qy
  • Qz
  • unknown
  • nparray_1
  • nparray_2
  • nparray_3
  • nparray_4
  • nparray_5

RQDecomp3x3_0 wraps cv2.RQDecomp3x3, the decomposition that camera-calibration people live on. Feed it any 3×3 matrix and it factors it into an upper-triangular matrix R and an orthogonal matrix Q - and when that matrix is a camera projection or calibration matrix, R and Q carry real meaning: roughly the intrinsic-like upper-triangular part and the rotation-like part. It's the math you do when you want to pull "how is the camera rotated" and "what does the shear/tilt look like" out of a single 3×3 blob.

Who this is for

Let me be straight about who this is for. If you're doing the modern depth-estimation / pose-recovery stuff the KB covers - MoGe point maps, Depth Anything 3 camera poses - you get poses out of the model and never touch a calibration matrix. RQ decomposition is classical computer vision: you've run something like camera calibration or a projection-matrix factorization and now you need the pieces separated for further processing. If that sentence doesn't describe you, this node is not going to pull you in, and that's the honest truth.

Inputs and outputs

Mechanically, src (NPARRAY, required) is the 3×3 input. The optional mtxR, mtxQ, Qx, Qy, Qz inputs are out-parameters - per the pack README's standing rule, leave them unwired and let OpenCV return them fresh. What comes back is the fun part: cv2.RQDecomp3x3 returns six things, the rotation decomposition plus the three Euler-angle axes. The pack's generator choked on the first return value (a Vec3d, which it doesn't support), so the first output is labeled unknown and typed None - a genuine auto-generation scar. Ignore it. The remaining five outputs (nparray_1 through nparray_5) are R, Q, and the Qx/Qy/Qz Euler-angle vectors, in OpenCV's order.

Using it

So the practical read: wire src in, read nparray_1..5 out, and mentally delete the unknown socket that refuses to connect to anything sensible. If you're building a calibration pipeline inside ComfyUI - you're a rare and determined person - these outputs feed whatever matrix-math step comes next.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python

Install is the pack standard: ComfyUI Manager → search "opencv-comfyui", or the commands above, then pip install opencv-contrib-python (the requirements.txt dependency; no models). The _0/_1 split is the MatLike/UMat overload thing, and both behave identically from the UI.

Gotchas

One warning worth repeating: everything in this pack is an NPARRAY, and src here is a matrix, not a picture. Feed it a converted image and you'll get an assertion error or, worse, a stack of nonsense matrices you'll try to render. If you need to double-check what a node produced, look at the OpenCV docs rather than guessing - that's the pack author's own advice, and it applies double to a decomposition like this one.

Categoryimage/OpenCV

Inputs (6)

NameTypeDefaultDescription
srcNPARRAY
mtxRoptNPARRAY
mtxQoptNPARRAY
QxoptNPARRAY
QyoptNPARRAY
QzoptNPARRAY

Outputs (6)

NameTypeDescription
unknownNone
nparray_1NPARRAY
nparray_2NPARRAY
nparray_3NPARRAY
nparray_4NPARRAY
nparray_5NPARRAY