Nodes/opencv-comfyui/OpenCV cornerEigenValsAndVecs_0
ComfyUI Node

OpenCV cornerEigenValsAndVecs_0

CornerEigenValsAndVecs_0

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV cornerEigenValsAndVecs_0
  • src
  • dst
  • nparray
blockSize
ksize
borderType

This node is cv2.cornerEigenValsAndVecs wearing a ComfyUI costume, and it's the one corner detector in the pack that shows you the actual math instead of just a verdict. Feed it a grayscale image and it doesn't tell you "here are the corners" - it gives you, per pixel, the eigenvalues and eigenvectors of the local gradient structure. If that sentence already sounds like you're back in linear algebra, that's the point: this is a primitive for people building real computer-vision pipelines (alignment, registration, structure-from-motion), not a thing you drop between a KSampler and a VAE Decode.

Honest framing up front: nobody on the SD subreddits is talking about this function, and that's not an accident. It's a classical OpenCV primitive from before diffusion existed. You reach for it when your workflow has actual geometry in it - frame alignment for video img2img, matching features across shots, camera calibration - and you need to know where corners are and how strong they are, not just see pretty dots.

How it works

At every pixel, OpenCV builds a 2×2 "structure tensor": the covariance of image gradients inside a small neighborhood (your blockSize). That matrix has two eigenvalues. Both large → strong corner (structure in every direction). One large, one near zero → an edge. Both tiny → flat. Harris later squashes those into one number; Shi-Tomasi takes the minimum of the two; this node just hands you everything.

The output is a single nparray with 6 channels per pixel: [λ1, λ2, x1, y1, x2, y2] - the two eigenvalues followed by the two eigenvector components. Important catch: this is not an image. Wire it into Nparrays2Image and you'll get that 'NoneType' object has no attribute 'shape' error the pack README warns about, because a 6-channel float array isn't viewable. You're meant to feed it onward - pull out channel 0 for the first eigenvalue, threshold it, use it as a quality map.

The inputs that matter

  • src - your nparray. It must be single-channel grayscale. Feed it RGB and OpenCV throws img.type() == CV_8UC1 assertion errors. Convert with cvtColor (code 6 for BGR2GRAY) first.
  • blockSize - the neighborhood size for the gradient covariance. Odd numbers, usually 3–7. Bigger = fewer, blobbier corners.
  • ksize - aperture of the Sobel derivative kernel, odd, 3 or 5 typical.
  • borderType - border extrapolation. Leave the default unless you know otherwise.
  • dst - ignore it. The pack keeps OpenCV's out-parameters as optional inputs, and the README's advice is blunt: don't feed them.

Install

This node ships with opencv-comfyui by geroldmeisinger. Easiest path: ComfyUI Manager → search opencv-comfyui (displayed as "OpenCV") → install. Or by hand:

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

Restart ComfyUI. The pack's requirements.txt wants opencv-contrib-python, numpy, torch - you almost certainly already have OpenCV as a transitive dependency of some other pack, but pip install opencv-python-contrib fixes it if not. No model downloads. Note the whole pack is auto-generated from cv2's type definitions, so the author's own warning applies: expect dragons, and these nodes are ugly on purpose.

Common issues

  • CV_8UC1 assertion → you fed it color. cvtColor to grayscale first.
  • Batch errors - Image2Nparray only accepts batch_size==1. Use ImageFromBatch (length 1) if your image comes in as a batch.
  • invalid syntax (<unknown>, line 0) → that's for the string-parsed inputs elsewhere; if you see it here you've wired a STRING parameter. This node's params are plain ints.
Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
srcNPARRAY
blockSizeINT
ksizeINT
borderTypeINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY