Nodes/opencv-comfyui/OpenCV getDefaultNewCameraMatrix_1
ComfyUI Node

OpenCV getDefaultNewCameraMatrix_1

The Twin of getDefaultNewCameraMatrix — They're the Same Node

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV getDefaultNewCameraMatrix_1
  • cameraMatrix
  • nparray
imgsize
centerPrincipalPoint

OpenCV getDefaultNewCameraMatrix_1 is a duplicate. The pack's generator (opencv-comfyui by geroldmeisinger) walks OpenCV's type stubs, numbers every overload it finds, and turns each into its own node. For cv2.getDefaultNewCameraMatrix, two of those overloads ended up with the same flattened signature - so getDefaultNewCameraMatrix_0 and getDefaultNewCameraMatrix_1 have identical inputs, identical behavior, and identical output. There is no version 2 with more features hiding in here. Pick whichever the search box suggests and move on.

What it does

Same as its twin: it takes a calibrated 3×3 camera matrix and returns a re-derived one. The one meaningful choice is centerPrincipalPoint - False keeps the principal point from your calibration, True re-centers it to the image center, which is handy when you want a textbook matrix for stereo rectification or for feeding into getOptimalNewCameraMatrix. It doesn't remove distortion and it doesn't touch pixels; it's a helper that produces cleaner camera matrices for the rest of your calibration pipeline.

The inputs and output

  • cameraMatrix (NPARRAY) - your 3×3 matrix as an OpenCV-style numpy array.
  • imgsize (STRING) - image size as a literal, e.g. [1920, 1080]. The brackets matter: the pack evaluates these strings with ast.literal_eval, so 1920, 1080 throws invalid syntax (<unknown>, line 0).
  • centerPrincipalPoint (BOOLEAN) - the only input that changes the result.
  • Output nparray (NPARRAY) - the adjusted 3×3 matrix, ready for undistort, initUndistortRectifyMap, or getOptimalNewCameraMatrix.

The broader camera-calibration story lives in getOptimalNewCameraMatrix - that's the one that handles distortion coefficients and gives you the crop ROI, i.e. the actual "make my lens-distorted photos straight" node. This one is for when you specifically want the matrix replaced, not the image transformed.

Install

Same as every node in the pack: ComfyUI Manager, search for opencv-comfyui (display name "OpenCV"), or:

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

Restart ComfyUI. No model files involved.

Gotchas worth remembering

The usual pack rules apply: NPARRAY means OpenCV numpy arrays, not Comfy IMAGE tensors, so run Image2Nparray before and Nparrays2Image after if pixels are involved, and keep batch size at 1. Format every composite literal with brackets. And don't waste time comparing _0 vs _1 - diffing their source just shows the same apply_function call twice. If one of them ever gets fixed downstream, the other probably won't, so you're better off standardizing on one and ignoring the duplicate entirely.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
cameraMatrixNPARRAY
imgsizeSTRING
centerPrincipalPointBOOLEAN

Outputs (1)

NameTypeDescription
nparrayNPARRAY