Nodes/opencv-comfyui/OpenCV findChessboardCorners_0
ComfyUI Node

OpenCV findChessboardCorners_0

The classic checkerboard detector, straight from OpenCV

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV findChessboardCorners_0
  • image
  • corners
  • bool
  • nparray
patternSize
flags

Photograph a printed checkerboard from a few angles, feed each shot to findChessboardCorners_0, and you get back the grid of interior corner points - the raw material of camera calibration, lens-distortion correction, and pose estimation. This node wraps cv2.findChessboardCorners, the workhorse OpenCV has shipped for a decade: it scans the image for a chessboard pattern of the size you asked for and returns the detected corners.

It's a pure detection node, and it's honest about that: it either finds the board or it doesn't, and it tells you which with its bool output. That's actually the nicest thing about it in a ComfyUI context - instead of silently producing garbage, it hands you a success flag you can wire into a switch or an early-exit.

The inputs that matter

  • image (NPARRAY) - the checkerboard photo, ideally a single 8-bit grayscale image. If you feed it color, OpenCV's docs say it converts internally, but converting yourself with cvtColor code 6 (BGR2GRAY) is the more reliable path and matches the pack's philosophy of explicit conversions.
  • patternSize (STRING) - the big one, and a classic trap. This is the number of interior corners, not the number of squares. A 10×7 board has 9×6 interior corners, so you type (9, 6). It's a Python-literal tuple string, so parentheses matter: (9, 6) works, 9, 6 throws the pack's documented invalid syntax error.
  • flags (INT) - detection hints, OR-ed together: 1 = adaptive threshold, 2 = normalize image, 4 = filter quads, 8 = fast check (a quick yes/no before the expensive search - handy in a loop). Start at 0 or 8.
  • corners (NPARRAY, optional) - OpenCV's out-parameter for the result. Leave it unplugged; the node returns the corners itself.

Two outputs: bool (did it find the board) and nparray (the corner points, ready to feed find4QuadCornerSubpix for refinement, or a calibration step).

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 people get burned

The patternSize count, almost always. Type the interior-corner count, not the square count, and don't drop the parentheses. The other trap is expecting detection to be forgiving - it isn't; a blurry or half-cropped board returns False, not a partial result. If you're getting False on boards that look findable, flip on flags 1|2|4 (threshold, normalize, filter) and shoot a sharper board.

One honest caveat: this is the older detector. For occluded, asymmetric, or non-square boards, findChessboardCornersSB_0 is strictly more robust. If the classic one keeps failing you, that's the upgrade path.

Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
imageNPARRAY
patternSizeSTRING
flagsINT
cornersoptNPARRAY

Outputs (2)

NameTypeDescription
boolBOOLEAN
nparrayNPARRAY