Nodes/ComfyUI CV/cv2.findChessboardCornersSB
ComfyUI Node

cv2.findChessboardCornersSB

Cv2.findChessboardCornersSB

By bmad4ever·Created 3 months ago·Updated 14 days ago· 1
cv2.findChessboardCornersSB
  • image
  • patternSize
  • bool
  • nparray
◄flagsnone (0)►

Same job as the classic detector, better tool. cv2.findChessboardCornersSB is OpenCV's sector-based chessboard finder: it handles blurred, distorted and off-angle boards that make the legacy detector return false, and - the part that matters most - it hands back corners that are already sub-pixel accurate, so you don't need a separate refinement pass.

If you're calibrating a phone, an action cam, a webcam that's spent years in a laptop lid, or anything with a rolling-shutter-ish smudge in the corners, start here.

Inputs and the flag set that actually differs

image is the board view. The socket takes IMAGE, MASK or NPARRAY; an IMAGE arrives as uint8 BGR frame 0, which is what SB wants, so a plain Load Image → this node wire is fine.

patternSize is the count of inner corners, ordered (points per row, points per column) - the number of squares minus one, per axis. It's a Size value: two components that travel as one, wired from CV Tuple or typed in place.

flags is where SB stops looking like its older sibling. The dropdown is none (0) plus the SB set: CALIB_CB_NORMALIZE_IMAGE (equalize the histogram before detection - cheap win on dim frames), CALIB_CB_EXHAUSTIVE (search much harder; slow, use it on the frames that keep failing), CALIB_CB_ACCURACY (upsample for better sub-pixel accuracy - the flag to enable when you want a calibration you'll actually ship), CALIB_CB_LARGER (allow a detected pattern larger than the one you asked for) and CALIB_CB_MARKER (require a marker on the board; OpenCV's recommendation when you need an accurate calibration). Notice what's absent: the adaptive-threshold and fast-check bits belong to the old detector and are ignored here, which is why the pack gives this node its own dropdown rather than reusing CV Chessboard Flags. Default is none (0), so the first thing you do on a stubborn board is toggle CALIB_CB_NORMALIZE_IMAGE, then CALIB_CB_ACCURACY.

Outputs are bool and nparray - the boolean is all-or-nothing as before, and the array is Nx1x2 corners in row-major order, ready for cv2_drawChessboardCorners, CV Grid Points → cv2_solvePnP, or a batch calibration node.

One caveat worth knowing before you enable CALIB_CB_LARGER: letting the detector find more than you asked for means the corner count isn't guaranteed to match patternSize anymore. If you care what it actually found, use the sibling node cv2_findChessboardCornersSBWithMeta, which returns the detector's own metadata alongside the corners.

Which detector should you pick

My take: SB unless you have a reason. It's the newer implementation, it tolerates the optical imperfections real cameras have, and its corners are already sub-pixel - so a chain of "detect with SB, then run cornerSubPix" is usually busywork, and running cv2_find4QuadCornerSubpix on top is a way to make good numbers slightly different.

The classic cv2.findChessboardCorners still earns its place when you're reproducing a tutorial, when you're after the flag behaviour of the older detector, or when the board is pristine and flat to the sensor and you'd rather not pay for the extra search. It is genuinely faster on easy input.

And if your actual goal is a calibrated camera rather than corner coordinates, don't assemble this by hand: CV Calibrate Camera (Chessboard) takes an IMAGE batch, finds the boards, refines, skips the views that fail, and gives you K, distortion coefficients and an RMS error. The raw wrappers are for when you want to see and control each step.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
pip install "opencv-contrib-python-headless~=5.0.0.93"

Or install "ComfyUI CV" via ComfyUI Manager, then restart. Python ≥ 3.12 and a recent ComfyUI on the V3 node API are required.

Common issues

Still false on every frame. Nine times out of ten it's patternSize: inner corners, not squares, and (columns, rows). After that: a board without a white border, JPEG-crushed edges, or so little of the frame filled that there's nothing to lock onto. CALIB_CB_EXHAUSTIVE is the honest last try before you reshoot.

It's slow. Yes - SB is doing more work per frame, and EXHAUSTIVE plus ACCURACY multiplies that. Detect on downscaled copies isn't a thing here (the corners are in the original pixel grid), so the fix is fewer, better views. Eight to twenty frames is a good calibration; forty mediocre ones is not.

Contrib nodes disappear. Installing a non-contrib opencv-python wheel over the contrib build empties the contrib submodules, since all OpenCV Python wheels share one site-packages/cv2. The pack ships tools/repair_opencv_contrib.py (--check, then --apply) for exactly this failure.

Categoryimage/CV/low-level/cv2 F

Inputs (3)

NameTypeDefaultDescription
imageNPARRAY,IMAGE,MASKSource chessboard view. It must be an 8-bit grayscale or color image. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size.
patternSizeCV_TUPLE0,0Number of inner corners per a chessboard row and column ( patternSize = cv::Size(points_per_row,points_per_column) = cv::Size(columns,rows) ). One value with 2 components (w, h) - it travels as a whole, so it cannot arrive half-connected. Wire it from 'CV Tuple' or type the components in place.
flagsoptSTRINGnone (0)Various operation flags that can be zero or a combination of the following values: - Normalize the image gamma with equalizeHist before detection. - Run an exhaustive search to improve detection rate. - Up sample input image to improve sub-pixel accuracy due to aliasing effects. - The detected pattern is allowed to be larger than patternSize (see description). - The detected pattern must have a marker (see description). This should be used if an accurate camera calibration is required. cv2.findChessboardCornersSB flags: one of none (0) plus any of CALIB_CB_NORMALIZE_IMAGE, CALIB_CB_EXHAUSTIVE, CALIB_CB_ACCURACY, CALIB_CB_LARGER, CALIB_CB_MARKER, pipe-joined (e.g. "none (0) | CALIB_CB_NORMALIZE_IMAGE"). In the UI this renders as a dropdown with one toggle per flag.

Outputs (2)

NameTypeDescription
boolBOOLEAN—
nparrayNPARRAY—