OpenCV decomposeProjectionMatrix_0
Pulling Camera Intrinsics, Pose, and Euler Angles Out of a Projection Matrix
- projMatrix
- cameraMatrix
- rotMatrix
- transVect
- rotMatrixX
- rotMatrixY
- rotMatrixZ
- eulerAngles
- nparray_0
- nparray_1
- nparray_2
- nparray_3
- nparray_4
- nparray_5
- nparray_6
OpenCV decomposeProjectionMatrix_0 takes a 3×4 camera projection matrix and decomposes it into everything a computer-vision person could want: the intrinsic camera matrix, the rotation matrix, the translation vector, and the Euler angles. In plain terms: given a single matrix that describes "how a camera sees the world," this node hands you where the camera is, which way it's pointing, and what its lens does to the light.
This is calibration/reconstruction math, not image processing - and it's about as far from "generative" as this pack gets. It exists because geroldmeisinger/opencv-comfyui auto-generates a node for every top-level cv2 function, and cv2.decomposeProjectionMatrix is one of ~635. If you're building augmented-reality, pose-estimation, or 3D-reconstruction pipelines on top of ComfyUI (matching the KB's broader deterministic-post-processing philosophy: no model, just math), this is the node.
How it works
A projection matrix P (3×4) maps 3D world points to 2D image points, and it's the product of the intrinsic matrix and the extrinsic [rotation | translation] pair. decomposeProjectionMatrix factors P into:
cameraMatrix- the 3×3 intrinsics (focal length, principal point).rotMatrix- the 3×3 rotation from world to camera coordinates.transVect- the 3×1 translation.rotMatrixX,rotMatrixY,rotMatrixZ- 3×3 rotation sub-matrices per axis.eulerAngles- 3×1 Euler angles derived from the rotation, useful when you want to know "the camera is tilted 12° down" instead of reading a matrix.
That's the whole output list, and it's why this node has seven outputs - one per return value.
Inputs and outputs
projMatrix(NPARRAY) - the 3×4 projection matrix. Float matrix, not an image - don't wireImage2Nparrayinto this and expect anything sensible.cameraMatrix,rotMatrix,transVect,rotMatrixX/Y/Z,eulerAngles(NPARRAY, optional) - out-parameters; leave them unconnected, the function fills them and you read the outputs.nparray_0throughnparray_6(outputs) - intrinsics, rotation, translation, axis rotations, Euler angles, in that order.
decomposeProjectionMatrix_1 is the identical MatLike/UMat twin.
Install
ComfyUI Manager (search opencv-comfyui) or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python
Restart ComfyUI. No models. Use opencv-contrib-python (the README's opencv-python-contrib is the wrong package name); conflicting OpenCV installs show up as Cannot import name 'guidedFilter' from 'cv2.ximgproc', with a known fix.
The trap
Seven float matrices come out, and ComfyUI will happily try to preview any of them as a picture - that's how you get the 'NoneType' object has no attribute 'shape' error from Nparrays2Image, or a screen of static. These outputs are data for other camera nodes, not images. And like everything in this pack, inputs must be batch_size==1 - for matrices that's trivially satisfied, since you're building them yourself.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| projMatrix | NPARRAY | — | |
| cameraMatrixopt | NPARRAY | — | |
| rotMatrixopt | NPARRAY | — | |
| transVectopt | NPARRAY | — | |
| rotMatrixXopt | NPARRAY | — | |
| rotMatrixYopt | NPARRAY | — | |
| rotMatrixZopt | NPARRAY | — | |
| eulerAnglesopt | NPARRAY | — |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| nparray_0 | NPARRAY | — |
| nparray_1 | NPARRAY | — |
| nparray_2 | NPARRAY | — |
| nparray_3 | NPARRAY | — |
| nparray_4 | NPARRAY | — |
| nparray_5 | NPARRAY | — |
| nparray_6 | NPARRAY | — |