Nodes/opencv-comfyui/OpenCV cornerMinEigenVal_0
ComfyUI Node

OpenCV cornerMinEigenVal_0

CornerMinEigenVal_0 — the Shi-Tomasi corner score, the one goodFeaturesToTrack trusts

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

If cornerHarris_0 is the famous corner detector, cornerMinEigenVal_0 is the one the serious pipelines actually prefer. It computes the Shi-Tomasi corner score: at each pixel it builds the same 2×2 gradient structure tensor, then takes the minimum of its two eigenvalues. Both large → corner. One large → edge. That minimum-eigenvalue test is exactly the quality measure cv2.goodFeaturesToTrack uses under the hood, which is why it's considered more reliable than Harris: it doesn't reward pure edges the way det − k·trace² can.

Straight talk about the context: this is another classical CV primitive in the auto-generated opencv-comfyui pack, and the SD community basically never talks about it - a quick search of the r/comfyui/r/StableDiffusion corpus turns up nothing, because people doing this work are coming from a vision background, not a diffusion one. You'll reach for it when your workflow needs stable, evenly-distributed feature points: frame-to-frame alignment for video img2img, image stitching, feature matching for registration, or camera-calibration marker detection. It's a tool for building a pipeline, not for decorating an image.

How it works

  1. Compute image gradients (Sobel, aperture ksize).
  2. Within a blockSize×blockSize neighborhood, accumulate the structure tensor - the gradient covariance.
  3. Eigen-decompose it and return min(λ1, λ2) per pixel.

The output is a single-channel float32 map of quality scores. Like Harris, it's not scaled for viewing - you're meant to threshold it (the classic recipe is keep everything above 0.01 × max), or better, feed the same score into a feature-selection step where you pick the strongest N points. The result reads as "every pixel's corner-ness, ranked," which is a nicer handle than Harris's signed response.

The inputs that matter

  • src - grayscale nparray. Color in → CV_8UC1 assertion; use cvtColor code 6 (BGR2GRAY).
  • blockSize - odd, 3–7. Neighborhood size for the tensor.
  • ksize - Sobel aperture, odd, 3 or 5.
  • borderType - leave the default.
  • dst - the pack's optional out-parameter; skip it per the README.

Install

Part of opencv-comfyui by geroldmeisinger. ComfyUI Manager → search opencv-comfyui → install, or:

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

Restart. Needs opencv-contrib-python (+ numpy, torch); OpenCV is usually already present from another pack. No model files.

Common issues

  • CV_8UC1 assertion → grayscale first, always.
  • Flat/black output → it's a raw float score map; threshold it before judging.
  • Batch > 1Image2Nparray only takes batch_size==1; split with ImageFromBatch.
  • _0 vs _1 → identical auto-generated overloads; either works.

The auto-generated pack is rough around the edges - "expect dragons" is the author's own warning - but the Shi-Tomasi math underneath is stable and unglamorous. Convert to gray, threshold the score, and you've got a quality corner map you can actually build on.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
srcNPARRAY
blockSizeINT
ksizeINT
borderTypeINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY