CV Barcode Detect
Detects and decodes 1-D product barcodes (EAN-8, EAN-13, UPC-A, UPC-E) with cv2.barcode.BarcodeDetector - the linear-barcode counterpart of 'CV QR Detect', and another cv2 CLASS the auto-generated wrappers cannot reach. It locates the bar region by its dense parallel gradients, rectifies it and reads the bar widths, so it copes with rotation, perspective and the curve of a bottle label. Outputs mirror the QR node - DATA only: 'bboxes' to the core 'Draw BBoxes', 'corners' + 'connections' to 'CV Draw Connections' for the exact quad, 'corners' + 'labels' to 'CV Draw Labels', 'text' to 'Preview as Text'. Zero barcodes is a valid result (empty outputs, found=false), never an error. Processes a single image (the first frame of a batch). NOTE: unlike QR there is no encoder in OpenCV - this node only reads.
- image
- found
- barcode_count
- text
- bboxes
- corners
- connections
- texts
- formats
- labels
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | NPARRAY,IMAGE | Image to scan. An IMAGE batch uses its first frame; an NPARRAY (gray/BGR, any dtype) is treated as one frame. 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. | |
| gradient_threshold | FLOAT | 640–255 | Minimum gradient magnitude for a pixel to count towards a bar region. LOWER it for faint, low-contrast or out-of-focus barcodes; raise it to reject busy background texture that looks like bars. |
| downsampling_thresholdopt | FLOAT | 51264–8192 | Images larger than this (in pixels, on the shorter side) are downsampled before the SEARCH - decoding still happens at full resolution. Raise it when a small barcode in a big photo is missed. |
| detector_scalesopt | STRING | 0.01, 0.03, 0.06, 0.08 | Comma-separated relative scales the detector searches at, as a fraction of the image size. Add a larger value (e.g. 0.2) when the barcode fills much of the frame, a smaller one when it is tiny. Blank = OpenCV's defaults. |
Outputs (9)
| Name | Type | Description |
|---|---|---|
| found | BOOLEAN | True when at least one barcode was located. Feed a 'Basic data handling: IfElse' to branch instead of gating a node with a boolean widget. |
| barcode_count | INT | Number of barcodes located. |
| text | STRING | Every decoded payload, one per line - wire into the core 'Preview as Text' (PreviewAny) node. Empty when nothing decoded. |
| bboxes | BOUNDING_BOX | One {x, y, width, height, score, label} dict per barcode (axis-aligned box around its 4 corners, label = decoded digits) - feed the core 'Draw BBoxes' node. |
| corners | NPARRAY | (N*4, 2) float32: the 4 corner points of every barcode, in order. Feed 'CV Draw Points', or 'CV Draw Connections'/'Draw Labels' with the matching outputs. Empty (0, 2) when nothing is found. |
| connections | NPARRAY | (N*4, 2) int32 edge index-pairs closing each barcode's quad, indexed into 'corners' - feed 'CV Draw Connections' to outline the rotated region exactly. |
| texts | NPARRAY | (N,) string array of the decoded payloads, one per barcode. An empty entry means the barcode was located but could not be read. |
| formats | NPARRAY | (N,) string array of the symbology per barcode ('EAN_13', 'EAN_8', 'UPC_A', 'UPC_E', or 'NONE' when only located). |
| labels | NPARRAY | (N*4,) string array aligned row-for-row with 'corners': each barcode's text on its FIRST corner, blank on the other three. Feed 'corners' + this to 'CV Draw Labels' to write the digits once per barcode. |