CV Chessboard Flags
CV Chessboard Flags — stop retyping 512+32 into six different detector nodes
- flags
- value
What this is for
A raw cv2 wrapper is a thin thing. cv2_findChessboardCorners takes an image, a pattern size and a flags integer, and if you've ever tried to set that integer from memory you know how it goes: is it 1, 2, or 3 for adaptive threshold plus normalize image, and what was FILTER_QUADS again?
This node is a flag authoring node. You configure the bits once, in a UI that shows one toggle per flag, and fan the result out to as many detector nodes as you like. It's the plumbing pattern the KB calls "one source, many consumers" - the same reason you'd wire one PrimitiveInt into five samplers instead of editing five widgets and forgetting the third one. Useful for this pack's nodes generally; the flag groups are actually generated for several families of cv2 calls (the chessboard one is just the group in front of you).
How it works
The widget is a single flags STRING of pipe-joined cv2 constant names, e.g. CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_NORMALIZE_IMAGE. The frontend extension doesn't hand you a text box - it renders a base dropdown plus one toggle per available flag and writes the joined string back, and the toggle bits are OR-ed together on the Python side. A typo in a constant name is a loud error at resolve time rather than a silently wrong integer, which is the behaviour you want from something you configured once weeks ago.
The two flag groups that matter here are the classic detector's and the SB one's, and they don't overlap cleanly:
ADAPTIVE_THRESH,FAST_CHECK,FILTER_QUADSdrive the classicfindChessboardCorners.EXHAUSTIVE,ACCURACY,LARGER,MARKERdrive the SB variants.NORMALIZE_IMAGEapplies to both.
None of this makes the detector smarter about a bad photo - it's tuning, and the SB variants are a different algorithm, not a flag on the same one.
Inputs and outputs
One input: flags, as above. Two outputs:
flags(STRING) - the pipe-joined string, wire it into theflagsinput of any number ofcv2_findChessboardCorners/cv2_findChessboardCornersSB/...SBWithMetanodes. They all now share one configuration.value(INT) - the resolved integer, for raw int flag parameters or for arithmetic you're doing by hand in aMathExpression.
That value output is the bit that makes this node more than cosmetic: the raw wrapper takes an int, so something has to resolve names to bits, and having that something be a node means the number you see in the graph came from named constants.
Install
Same pack as the rest, and there's no separate dependency for a flag node:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
# restart ComfyUI
ComfyUI Manager: search ComfyUI CV (publisher bmad4ever). The pack wants Python ≥ 3.12, a recent V3-node-API ComfyUI, and opencv-contrib-python-headless~=5.0.0.93 (the NORMALIZE_IMAGE/ADAPTIVE_THRESH constants are core OpenCV, but the pack as a whole leans on contrib elsewhere).
Common issues
- The toggles don't appear. The pipe-string input renders as plain text unless the frontend half of the pack loaded. Hard-reload the page; a cached tab from before the install shows a text field.
- A flag seems to do nothing. Expected in places - a bit the target function doesn't use is ignored rather than rejected. On the chessboard family specifically, the SB-only bits are inert on the classic detector and vice versa, so setting
EXHAUSTIVEon a plainfindChessboardCornersis a no-op. - You typed a constant name by hand and got an error. That's the intended failure: better a loud error than an OR of zero and something wrong downstream.
- The node is missing entirely. This one is generated from the installed OpenCV's constant set, so a stripped or non-contrib build can drop it.
tools/repair_opencv_contrib.py --check.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| flags | STRING | CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_NORMALIZE_IMAGE | Pipe-joined cv2 constant names, e.g. "CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_NORMALIZE_IMAGE | CALIB_CB_ADAPTIVE_THRESH". In the UI this renders as a base dropdown with one toggle per flag. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| flags | STRING | The pipe-joined flags string - wire it into the flags input of cv2_findChessboardCorners / cv2_findChessboardCornersSB(WithMeta) nodes. |
| value | INT | The resolved integer (constants OR-ed together). |