Nodes/opencv-comfyui/OpenCV estimateChessboardSharpness_0
ComfyUI Node

OpenCV estimateChessboardSharpness_0

Measuring focus sharpness of a calibration board — yes, in ComfyUI

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV estimateChessboardSharpness_0
  • image
  • corners
  • sharpness
  • literal
  • nparray
patternSize
rise_distance
vertical

This is the pack's oddball, and it's worth knowing what it is before you dismiss it: estimateChessboardSharpness scores how in focus a chessboard calibration image is. OpenCV uses it in autofocus and camera-calibration pipelines to decide which of a burst of captures is the sharpest one to calibrate against. It's from the calib3d module - the calibration corner of OpenCV - and it got swept into opencv-comfyui (geroldmeisinger/opencv-comfyui) along with all the other top-level functions when the pack was auto-generated.

Why would anyone run this in ComfyUI? Honest answer: almost nobody, unless you're building a camera-calibration workflow that starts from images ComfyUI can load and process. If you're doing that - say, tuning an autofocus rig or vetting calibration captures - this node is actually a nice fit, because the pack also ships findChessboardCorners and findChessboardCornersSB, which produce the corners input this node wants. In the broader picture, it belongs to the deterministic post-processing layer: no model, no generation, pure image analysis.

How it works

Given a detected chessboard, the function looks at the gradient across each square edge - the "rise" from dark to light - and measures how abrupt it is. A sharp capture has steep, fast transitions; a blurry one has slow ramps. It reports an average sharpness score (higher = better focus) and a per-region sharpness map. rise_distance controls the range over which the transition is evaluated (0.8 is the OpenCV default), and vertical picks which edge orientation to analyze (default True = vertical edges).

Inputs and outputs

  • image (NPARRAY) - the calibration image, grayscale (the -215 assertion error is what you get if you skip converting with cvtColor code 6).
  • patternSize (STRING) - the board's internal corner count as a Python literal, e.g. (7, 6) for a 7×6 corner grid. This is a string input parsed with literal_eval, so correct syntax matters.
  • corners (NPARRAY) - the detected corner coordinates, from findChessboardCorners-style nodes in the same pack.
  • rise_distance (FLOAT) - edge-transition measurement range, 0.8 default.
  • vertical (BOOLEAN) - analyze vertical edges (default True).
  • sharpness (NPARRAY, optional) - out-parameter; leave unconnected.
  • Outputs: literal (STRING) - the mean sharpness value(s), returned as a string because the underlying function returns a tuple of floats. nparray - the per-region sharpness map.

Wiring it up

The output naming tells you everything about this pack's rough edges: the primary result comes out as a string, and you'll be parsing that number yourself to make decisions (e.g. comparing sharpness across captures). Not pretty, but workable - and the author says the whole pack is auto-generated and to "expect dragons."

Install

ComfyUI Manager (search "opencv-comfyui") or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, then restart. Dependencies: opencv-contrib-python, numpy, torch; no model files. Gotchas: grayscale input required, patternSize must be valid Python-literal syntax ((7, 6), not 7,6), and Image2Nparray only accepts batch_size 1. If you're not doing calibration work, this is a skip - for general sharpness there are simpler image-analysis routes.

Categoryimage/OpenCV

Inputs (6)

NameTypeDefaultDescription
imageNPARRAY
patternSizeSTRING
cornersNPARRAY
rise_distanceFLOAT
verticalBOOLEAN
sharpnessoptNPARRAY

Outputs (2)

NameTypeDescription
literalSTRING
nparrayNPARRAY