Nodes/opencv-comfyui/OpenCV cornerHarris_1
ComfyUI Node

OpenCV cornerHarris_1

CornerHarris_1 — same Harris detector, but let's talk about the k knob

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

Yes, this is the twin. cornerHarris_1 and cornerHarris_0 both call cv2.cornerHarris with identical arguments; the pack's generator emitted one node per OpenCV overload (MatLike vs UMat) and the difference is invisible from your side of the wire. Pick either and move on. What's actually worth your time is the one knob this detector has that nobody bothers to explain: k.

Because here's the thing - almost everyone who uses Harris in a graph leaves k at some default and then wonders why the output is garbage. The k in R = det(M) − k·trace(M)² decides how much the detector trusts "edge-ness" as opposed to pure corner-ness. Too high and you suppress weak corners into nothing. Too low and every slightly-structured patch lights up. The canonical OpenCV default is 0.04; bump toward 0.06 for cleaner, sparser corners, drop toward 0.03 if you're losing the corners you care about. There's no magic value - it's a threshold over your image's texture budget, and you'll tune it per workflow.

What you get out

A single nparray, single-channel float32 response map. Every pixel holds a Harris score. It is not a viewable image and it is not a mask yet. The pattern you want:

  1. Grayscale the input (cvtColor, code 6).
  2. Run cornerHarris_1.
  3. Threshold: keep pixels above 0.01 × max(response) - that's the standard OpenCV recipe, and it scales automatically with the image.

That thresholded map is your corner mask, ready to feed an alignment or feature-matching stage.

Inputs worth touching

  • src - grayscale nparray. Color triggers the CV_8UC1 assertion.
  • blockSize - odd, 3–7. The neighborhood over which gradients are averaged.
  • ksize - Sobel aperture, odd, 3 or 5.
  • k - the parameter above. This is the one you'll actually tune.
  • borderType - leave it.
  • dst - optional out-parameter; the README's advice is to leave it unconnected.

Install

ComfyUI Manager → search opencv-comfyui → install, or:

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

Restart. Requirements are opencv-contrib-python + numpy + torch; OpenCV is probably already installed as a side effect of another node pack. No models to fetch.

Gotchas

The _1 suffix means nothing here - it's an auto-generated overload twin, not an improved version. If you go looking for which one "works," you'll find they both work identically, which is itself the answer. The real gotchas are the ones this whole pack shares: grayscale input required, batch size 1 only (use ImageFromBatch otherwise), and the threshold-before-viewing step. Keep those three straight and Harris is a boring, reliable workhorse - which is exactly what you want from geometry code.

Categoryimage/OpenCV

Inputs (6)

NameTypeDefaultDescription
srcNPARRAY
blockSizeINT
ksizeINT
kFLOAT
borderTypeINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY