Nodes/ComfyUI CV/cv2.checkChessboard
ComfyUI Node

cv2.checkChessboard

Throw out the calibration shot before it poisons the fit

By bmad4ever·Created 4 months ago·Updated 14 days ago· 1
cv2.checkChessboard
  • img
  • size
  • bool

One boolean out of a picture: is there a chessboard of this size in this frame? That's the whole node. It's OpenCV 5's quick validity check, wrapped raw in comfyui_cv - the pack of ~470 cv2.* nodes - and it earns its keep as the gate in front of a camera calibration, where one blurry or half-out-of-frame board can drag the whole intrinsic estimate off.

Worth saying up front: camera calibration is a niche corner of ComfyUI, and if you've never shot a checkerboard you will never need this. If you are calibrating - undistorting a lens before a geometry pipeline, or feeding intrinsics to the pack's 3D nodes - this is the cheap first-pass filter.

Why a pre-check exists at all

Chessboard detection is all-or-nothing. As the pack's own docs put it when describing the ChArUco alternative, "a plain chessboard view is thrown away unless every inner corner is visible." That means a photo where the board runs off the edge, or a corner is in shadow, or the whole thing is motion-blurred, doesn't fail loudly - it just isn't found, and the calibration quietly runs on fewer views than you thought you shot. A boolean pre-check lets you see that in the graph instead of discovering it in the reprojection error.

It's also useful as a filter over a batch: shoot thirty views of the board, check each, drop the failures, and calibrate on what's left.

Inputs and output

  • img (required) - the candidate view. Accepts NPARRAY, IMAGE or MASK; an IMAGE link is converted to uint8 BGR and only frame 0 of a batch is used, so a 30-frame calibration batch needs per-frame handling rather than one call.
  • size (required, default (0,0)) - the board size as one composite CV_TUPLE, (w, h). Follow the corner-count convention the pack's own calibration nodes use: it's the number of inner corners per row and column, not the number of squares. A board with 10 columns and 7 rows of squares is (9, 6). Getting this backwards is the single most common calibration mistake in the entire OpenCV ecosystem, and it's a mistake this node will happily confirm by returning false.

One output: bool - the author's return doc reads simply "Whether a chessboard was found."

Wire it wherever a decision needs making. A BOOLEAN socket is the selector on an A/B switch in ComfyUI's plumbing layer - so you can route a good view into the calibration path and a bad one into a discard or a "log this filename" branch. That's the entire design of the node: it converts "is this shot usable" into something the graph can route on.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv

Restart, or Manager → search "comfyui_cv". Python ≥ 3.12, a recent ComfyUI on the V3 node API, and:

pip install "opencv-contrib-python-headless~=5.0.0.93"

No models - it's a pattern check, not a detector network.

Common issues

The node isn't in the menu at all. checkChessboard is a 5.x entry point. The pack builds its registry from whatever your installed OpenCV exposes and skips what it can't find, so an older or non-contrib cv2 means the node silently doesn't exist. tools/repair_opencv_contrib.py --check will tell you whether your OpenCV install is the problem.

It always returns false. Nine times out of ten: size is the square count instead of the corner count, or it's (rows, cols) instead of (cols, rows). The other time: the board genuinely isn't fully visible, which is the answer the node exists to give you.

You got true and calibration still fails. This is a validity check, not a quality check. A sharp-looking boolean says a board was found, not that the corners are sub-pixel accurate or that your thirty views cover enough of the frame to estimate distortion. Coverage is what actually matters - the pack's ChArUco calibration path exists because requiring a fully visible board makes covering the image corners (where distortion lives) hardest of all.

You're filtering a batch and it only checks one frame. An IMAGE link gives this node frame 0. Split the batch, or drive the check per frame.

Categoryimage/CV/low-level/cv2 C

Inputs (2)

NameTypeDefaultDescription
imgNPARRAY,IMAGE,MASKSource chessboard view. 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.
sizeCV_TUPLE0,0Size of the chessboard. 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.

Outputs (1)

NameTypeDescription
boolBOOLEAN—