Nodes/opencv-comfyui/OpenCV goodFeaturesToTrackWithQuality_0
ComfyUI Node

OpenCV goodFeaturesToTrackWithQuality_0

Corners, with a receipt showing how good each one is

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV goodFeaturesToTrackWithQuality_0
  • image
  • mask
  • corners
  • cornersQuality
  • nparray_0
  • nparray_1
maxCorners
qualityLevel
minDistance
blockSize
gradientSize
useHarrisDetector
k

goodFeaturesToTrackWithQuality_0 is the corner detector that doesn't just hand you points - it hands you a score for every point. Regular goodFeaturesToTrack returns an N×1×2 array of (x, y) corners and stops there. This variant also returns the per-corner quality value, so instead of trusting the global qualityLevel cutoff, you can look at each corner's actual strength and filter by it yourself. That extra output is the whole point, and for tracking or matching work it's genuinely nice to have.

What you feed it

The schema is the "mask + gradientSize" variant, so it shares the newer API with goodFeaturesToTrack_2:

  • image (NPARRAY): BGR input from Image2Nparray.
  • maxCorners (INT): cap on returned corners.
  • qualityLevel (FLOAT): fraction of the best corner's score used as the floor (classic 0.01).
  • minDistance (FLOAT): minimum pixel separation.
  • mask (NPARRAY): required, single-channel, nonzero = search area.
  • blockSize (INT): gradient covariance window (3 or 7).
  • gradientSize (INT): pre-gradient blur size, odd, typically 37.
  • useHarrisDetector (BOOLEAN) and k (FLOAT): Harris path; leave False/0.04 for Shi-Tomasi.

Optional corners and cornersQuality are out-parameters from the C++ API - leave them disconnected; the function allocates its own outputs, which is what you get back.

What comes out

Two sockets:

  • nparray_0: the corners - N×1×2 float32, (x, y) points.
  • nparray_1: the quality scores - N×1 float32, one per corner in the same order.

The scores are the same internal values the detector uses to rank corners, exposed instead of discarded. Practical use: take nparray_1, compare against a threshold, and keep only the corners whose score clears it - a per-run filter that's independent of the global qualityLevel. That's the workflow trick this node exists for. If you don't need scores, the plain goodFeaturesToTrack nodes are simpler and slightly faster.

Same trap as the whole family: both outputs are point/score arrays, not images. Drawing points requires the pack's circle node; Nparrays2Image will choke with 'NoneType' object has no attribute 'shape'.

Install

Standard pack install:

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

or ComfyUI Manager, search "opencv-comfyui", restart. Needs opencv-contrib-python; numpy/torch are already there. No models, no keys. The one environment gotcha to know: Cannot import name 'guidedFilter' from 'cv2.ximgproc' at startup means duplicate OpenCV wheels - keep a single opencv-contrib-python.

One more thing worth knowing: this API is newer (OpenCV 4.5.3+), so if you're on an old wheel, getVersionString_0 will show it and the node may not exist in your build. And the _1 node beside this one is an identical overload - use _0.

Categoryimage/OpenCV

Inputs (11)

NameTypeDefaultDescription
imageNPARRAY
maxCornersINT
qualityLevelFLOAT
minDistanceFLOAT
maskNPARRAY
blockSizeINT
gradientSizeINT
useHarrisDetectorBOOLEAN
kFLOAT
cornersoptNPARRAY
cornersQualityoptNPARRAY

Outputs (2)

NameTypeDescription
nparray_0NPARRAY
nparray_1NPARRAY