OpenCV calibrationMatrixValues_0
Your camera's FOV and focal length, solved in-graph instead of by hand
- cameraMatrix
- float_0
- float_1
- float_2
- literal
- float_4
If you've ever needed the field of view of a camera and reached for a calculator, this node is that calculator, bolted into the graph. calibrationMatrixValues is the OpenCV function that takes a 3x3 camera intrinsic matrix and turns it into the numbers people actually quote: horizontal FOV, vertical FOV, focal length, principal point, and aspect ratio. This node is a straight auto-generated wrapper around it.
Honest framing first: this is a calibration and optics node, not an image-effects node. If you're doing portrait or upscaling workflows you'll never touch it. You reach for it when you're doing camera calibration (chessboard corners, calibrateCamera, fisheye models) or any 3D-to-2D projection math where knowing your lens geometry matters - think virtual camera FOV for depth-aware compositing or matching a 3D render to a real lens.
How it works. The intrinsic matrix encodes, in pixels, the focal length and the optical center of a camera. calibrationMatrixValues does the trigonometry that recovers the physical meaning: combine focal length (in pixels) with the sensor's physical dimensions (in mm) and you get the angular field of view. The five outputs are, in order:
float_0- horizontal FOV (degrees)float_1- vertical FOV (degrees)float_2- focal length (mm)literal- principal point, returned as aPoint2dand printed as a stringfloat_4- aspect ratio of the image
The inputs that matter. cameraMatrix is an NPARRAY - a 3x3 float matrix, typically the one you got from calibrating a camera or from a lens-distortion solver. imageSize is a STRING, and this is where the pack's quirks bite: composite types are entered as Python literals, so use (640, 480), not "640x480" - the node parses the string with literal_eval, and the wrong syntax throws the README's invalid syntax (unknown, line 0) error. apertureWidth and apertureHeight are FLOAT inputs (in mm). Here's the trap: if you leave them at 0, FOV and focal length silently come out 0 too. That's not a bug, that's OpenCV telling you it needs sensor dimensions to compute angles. Set real values (or your sensor's nominal size) if you want real numbers back. The aspect ratio comes out regardless.
Install. This ships in the opencv-comfyui pack by geroldmeisinger. Easiest path is ComfyUI Manager - search "OpenCV" and install, then restart. Manually it's:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib # the pack's real dependency
No model files, no heavy downloads beyond OpenCV itself. Remember the pack's representation rule: ComfyUI IMAGE tensors are RGB 0..1 float; OpenCV works on BGR 0..255 uint8 nparrays. Bridge with Image2Nparray / Nparrays2Image, and keep batches to size 1.
One last thing: the pack auto-generated one node per type-definition overload, which is why there's a calibrationMatrixValues_1 that looks identical to this one. They're near-duplicates - pick either and move on. And expect dragons: the author says so himself.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| cameraMatrix | NPARRAY | — | |
| imageSize | STRING | — | |
| apertureWidth | FLOAT | — | |
| apertureHeight | FLOAT | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| float_0 | FLOAT | — |
| float_1 | FLOAT | — |
| float_2 | FLOAT | — |
| literal | STRING | — |
| float_4 | FLOAT | — |