Recognize Barcodes

Recognize barcodes in video

Overview

The Recognize Barcodes node decodes barcodes detected by an AI model, and adds metadata to the frame metadata.

Suggested use : AI Model Node (with Barcode model) -> Track Objects Node -> Recognize Barcodes Node

Inputs & Outputs

  • Inputs : 1, Media Format : Raw Video
  • Outputs : 1, Media Format: Raw Video
  • Output Metadata : Barcode Information

Properties

PropertyDescriptionTypeDefaultRequired
barcode_typesComma-separated list of barcode types to recognize. Leave empty to detect all types. Options: AZTEC (ZXing engine only) (aztec); CODABAR (codabar); CODE128 (code128); CODE39 (code39); CODE93 (code93); COMPOSITE (ZBar engine only) (composite); DATAMATRIX (ZXing engine only) (datamatrix); DATABAR (databar); DATABAR EXPANDED (databar_exp); EAN2 (ZBar engine only) (ean2); EAN5 (ZBar engine only) (ean5); EAN8 (ean8); EAN13 (ean13); I25 (i25); ISBN10 (ZBar engine only) (isbn10); ISBN13 (ZBar engine only) (isbn13); MAXICODE (maxicode); PARTIAL (partial); PDF417 (pdf417); QRCODE (qrcode); MICROQRCODE (ZXing engine only) (microqrcode); RMQRCODE (ZXing engine only) (rmqrcode); UPCA (upca); UPCE (upce); All Linear Codes (ZXing engine only) (linearcodes); All Matrix Codes (ZXing engine only) (matrixcodes). Format: array of selected option values.string[]nullNo
display_infoDisplay barcode info on video?booltrueNo
preprocessEnables preprocessing to enhance barcode image quality, which might improve detection rates. Options: Upscale (if too small) (upscale); Downscale (if too big) (downscale); Sharpen (sharpen); Rotate (attempt to straighten) (rotate). Format: array of selected option values.string[]nullNo
process_detected_barcodes_onlyDisable to scan entire image for barcodes and increase processing time. Useful if the model doesn't detect barcodes well.booltrueNo
watchlistComma separated list of barcodes to watch for.stringnullNo
watchlist_toleranceAllow barcodes to differ by this number of characters from the watchlist. Unit: characters.number0No
barcode_engineSelect a barcode decoding engine. Options: ZXing (zxing); ZBar (zbar).enumzxingYes
retention_durationAfter this interval, a barcode that was seen previously will be treated as a new barcode. Unit: seconds.float60No

Output Metadata

The fields below are declared by this node's metadata schema; the JSON values are representative examples.

PathTypeDescription
nodes.<node_id>.barcode_countintegerNumber of decoded barcodes in the current frame.
nodes.<node_id>.barcode_count_deltaintegerWhen one or more new barcodes are recognized
nodes.<node_id>.watchlist_entered_deltaintegerWhen one or more new watchlist barcodes are recognized
nodes.<node_id>.watchlist_exited_deltaintegerWhen one or more watchlist barcodes are no longer present
nodes.<node_id>.barcodes[].typestringDecoded barcode symbology.
nodes.<node_id>.barcodes[].datastringDecoded barcode contents.
nodes.<node_id>.barcodes[].coordsarrayArray of four numbers containing the barcode bounding box as x, y, width, and height.
nodes.<node_id>.barcodes[].idintegerAssociated tracked object ID, or -1 for a full-frame decode.
nodes.<node_id>.barcodes[].watchlist_matchbooleanBoolean indicating whether the decoded value matched the configured watchlist.
nodes.<node_id>.barcodes[].watchlist_barcodestringConfigured watchlist value that matched this barcode, if any.
nodes.<node_id>.typestringIdentifies the node type that produced this metadata.

JSON example

{
  "nodes": {
    "annotate_barcode1": {
      "barcode_count": 2,
      "barcode_count_delta": 1,
      "barcodes": [
        {
          "coords": [
            104,
            205
          ],
          "data": "124314072131",
          "id": 1203112309710239,
          "type": "EAN13",
          "watchlist_barcode": "value",
          "watchlist_match": false
        },
        {
          "coords": [
            410,
            445
          ],
          "data": "203927812",
          "id": 102397932481,
          "type": "CODE128",
          "watchlist_barcode": "value",
          "watchlist_match": false
        }
      ],
      "type": "annotate_barcode",
      "watchlist_entered_delta": 0,
      "watchlist_exited_delta": 0
    }
  }
}

Object labels and attributes

  • Object labels/classes added: None.
  • Object attribute labels/classes added: Recognized barcode data (11000), barcode type (11001), and watchlist for a match (11002).

The following information is added to the detected object's "attributes" array:

"class_id""label""probability"
11000The recognized barcode result (string)The barcode recognition confidence
11001The recognized barcode type (string)The barcode recognition confidence
11002watchlist when the barcode matches1.0
"objects": [{
    "id": 5750484150146564100,
    "label": "barcode",
    "class_id": 0,
    "probability": 0.98,
    "rect": {
        "width": 47,
        "top": 201,
        "left": 656,
        "height": 25.
    },
    "attributes": [{
        "label": "124314072131",
        "class_id": 11000,
        "probability": 1.0,
    },
    {
        "label": "EAN13",
        "class_id": 11001,
        "probability": 1.0,
    }]
}]

Did this page help you?