Nodes/opencv-comfyui/OpenCV find4QuadCornerSubpix_0
ComfyUI Node

OpenCV find4QuadCornerSubpix_0

Subpixel corner refinement for calibration work

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV find4QuadCornerSubpix_0
  • img
  • corners
  • bool
  • nparray
region_size

If you're doing camera calibration, or anything that needs to know where a point really is to sub-pixel precision, this is your node. find4QuadCornerSubpix_0 wraps cv2.find4QuadCornerSubpix, a helper that takes rough corner locations on a quadrilateral (like the four corners of a detected checkerboard square) and refines them to subpixel accuracy by fitting the local gradients. It's the "make the approximate corners exact" step that calibration and lens-distortion math depend on - you can't compute a camera matrix worth anything from corners that are off by half a pixel.

It's a niche node, and it's a "this is OpenCV, not ComfyUI" node. It takes an image and a set of initial corner guesses, nudges those guesses to their true positions, and tells you whether it succeeded. You reach for it as part of a computer-vision pipeline - after a coarse detector finds the checkerboard, before the calibration solver consumes the refined corners.

The inputs that matter

  • img (NPARRAY) - the image the corners live in. Grayscale works best; this is a gradient-fitting operation, and it wants a single-channel 8-bit or float array. Convert with cvtColor code 6 (BGR2GRAY) if you're coming in with color.
  • corners (NPARRAY) - your initial corner guesses, as an array of (x, y) points. This should come from a detector - in this pack, findChessboardCorners or findChessboardCornersSB output exactly the corner arrays this node wants to refine.
  • region_size (STRING) - the search region around each corner, and another of this pack's literal-string parameters. Type it as a Python tuple: (5, 5). Bigger region = more search = slower but more tolerant of bad initial guesses.

Two outputs: bool - whether refinement succeeded for all corners - and nparray - the refined corner coordinates, ready to feed a calibration or perspective transform.

Installing it

One of ~600 nodes in geroldmeisinger/opencv-comfyui. ComfyUI Manager → search opencv-comfyui, or:

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

then restart. Needs opencv-contrib-python, numpy, torch. If startup fails with Cannot import name 'guidedFilter' from 'cv2.ximgproc', conflicting OpenCV installs - consolidate to one.

Pack rules: nparrays in/out (Image2Nparray / Nparrays2Image), batch size 1.

Where it fits

Honest framing: this node is at the deep end of the pack. It exists to serve calibration pipelines, and ComfyUI isn't usually where those live - most people doing calibration are in plain Python or a dedicated CV tool. But if you're building a ComfyUI workflow that detects checkerboards and needs to hand refined corners to a geometry step, find4QuadCornerSubpix_0 is the missing link between "found the board" (findChessboardCorners) and "trust the numbers." Just remember the bool output: refinement failing silently is a real failure mode, so check it before you trust the corners. The _1 twin is identical - no reason to prefer it.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
imgNPARRAY
cornersNPARRAY
region_sizeSTRING

Outputs (2)

NameTypeDescription
boolBOOLEAN
nparrayNPARRAY