Nodes/opencv-comfyui/OpenCV preCornerDetect_1
ComfyUI Node

OpenCV preCornerDetect_1

PreCornerDetect_1 — what that float map is actually for, and why your image looks like static

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

First, the twin thing, so you don't go looking for a difference that isn't there: preCornerDetect_1 and preCornerDetect_0 are both ports of cv2.preCornerDetect, generated separately because OpenCV's stubs declare the function more than once. Identical inputs - src, ksize, borderType - identical float nparray output. Use either.

The thing most people hit on their first try with this node: you feed it an image, wire the output to a preview, and get back something that looks like gray static. That's not a bug. preCornerDetect returns a corner response map, not a picture. Every pixel is a score for "corner-ness", centered around zero - negative in flat regions, spiking positive at corners. Displayed raw, that's noise to the eye and gold to a threshold operation.

What the map is for

The response is the "pre-corner" stage of a classic pipeline: it combines second-order derivatives (Dxx, Dyy, Dxy) into a harmonic-mean response that peaks at corners and vanishes on straight edges. Once you have it, you don't look at it - you process it:

  1. Threshold it (keep only pixels above a cutoff - those are corner candidates).
  2. Optionally run non-maximum suppression so corners don't bunch up.
  3. Feed the survivors into cornerSubPix for sub-pixel refinement - that's the "pre" paying off, since the whole point is handing cornerSubPix a good starting response.

If you're doing image alignment, feature matching, or camera-calibration-style work inside ComfyUI, that's the chain. preCornerDetect_1 is the first rung, and there's no shortcut around it.

The knobs, without the guesswork

  • ksize (INT) - Sobel aperture, odd numbers only. 3 is the default and fine to start; 57 blur more and return fewer, more reliable corners. If your map is too noisy, nudge this up.
  • borderType (INT) - an enum, which is this pack's way of making things "interesting". 1 = BORDER_REPLICATE, 4 = BORDER_REFLECT_101 (the OpenCV default). For normal images either is fine.
  • src must be single-channel and float. Grayscale it (cvtColor code 6) and convert to float before wiring it in, or you'll get a type assertion. This is the #1 failure with this node, and it's silent until you run.

The optional dst is an OpenCV out-parameter - leave it unconnected, per the pack README.

Install and context

Same as the whole pack: ComfyUI Manager → search "opencv-comfyui", or

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

restart, then pip install opencv-contrib-python. Work through Image2Nparray (batch size 1 only; ImageFromBatch length 1 fixes the error). And remember the author's own warning - Gerold Meisinger released this pack on r/comfyui in April 2025 describing it as auto-generated, "ugly and complex to use. Expect dragons!" Nodes like this one are the reason: useful, precise, and absolutely not hiding their complexity from you.

Honest verdict: if your work touches real-image vision tasks, this is a genuinely solid primitive. If you're generating pretty pictures, skip it - you've got nothing to corner-detect. But when you do need it, the float-map behavior and the pipeline above are exactly how it's supposed to work.

Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
srcNPARRAY
ksizeINT
borderTypeINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY