Nodes/opencv-comfyui/OpenCV findTransformECC_3
ComfyUI Node

OpenCV findTransformECC_3

FindTransformECC_2's twin — optional mask, identical math

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV findTransformECC_3
  • templateImage
  • inputImage
  • warpMatrix
  • inputMask
  • float
  • nparray
motionType
criteria

OpenCV findTransformECC_3 is findTransformECC_2's UMat twin, and that's the whole story. Same required inputs (templateImage, inputImage, warpMatrix, motionType, criteria), same optional inputMask, same cv2.findTransformECC call, same outputs (float ECC score + nparray refined warp matrix). The pack generates a node for every OpenCV overload - MatLike and UMat both - so you get pairs like this throughout. Nothing behaves differently between them.

The substance is in the _2 article. The short version: ECC aligns an input image to a template by refining a starting warp to maximize correlation. motionType 03 picks translation / euclidean / affine / homography; criteria is a string literal like (3, 50, 0.001); warpMatrix should start at identity. The outputs are a quality score and the transform - wire the transform into warpPerspective for the actual aligned image, and use the score to know whether the alignment is trustworthy.

The notes that keep coming up

  • Grayscale only. ECC asserts on multi-channel input (img.type() == CV_8UC1). cvtColor with code = 6 (BGR→GRAY) before this node, both inputs.
  • Local optimizer. A bad initial warpMatrix gives a confidently wrong result. Identity start, and trust the score, not your eyes.
  • Non-image outputs. A float and a matrix. The 'NoneType' object has no attribute 'shape' error is what you get for trying to preview the matrix like a photo.

Install

Same routine. ComfyUI Manager → search opencv-comfyui → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui

requirements.txt installs opencv-contrib-python, numpy, torch. If the pack doesn't register, it's almost always the cv2 import failing from a conflicting OpenCV install (Cannot import name 'guidedFilter' is the usual symptom).

Use _2 or _3, whichever your workflow references - they're interchangeable. And if you want the mask and Gaussian-smoothing inputs required rather than optional, that's the _0/_1 pair.

Categoryimage/OpenCV

Inputs (6)

NameTypeDefaultDescription
templateImageNPARRAY
inputImageNPARRAY
warpMatrixNPARRAY
motionTypeINT
criteriaSTRING
inputMaskoptNPARRAY

Outputs (2)

NameTypeDescription
floatFLOAT
nparrayNPARRAY