Skip to content

Barcode Reader and Verifier for Node-RED ​

@rosepetal/node-red-contrib-barcode (@rosepetal/node-red-contrib-barcode-reader up to 1.5.2) provides 2 nodes for Node-RED: a multi-decoder reader of barcodes and QR codes, and a verifier that grades the print quality of 1D barcodes against ISO/IEC 15416 and the GS1 symbol specification tables.

Installation ​

bash
cd ~/.node-red
npm install @rosepetal/node-red-contrib-barcode

Or search @rosepetal/node-red-contrib-barcode in the Node-RED Palette Manager.

Up to 1.5.2 the package was @rosepetal/node-red-contrib-barcode-reader; until the first version under the new name is published, it installs under its old name. On a machine that has the old package, uninstall it, install the new one and restart Node-RED: both register the same node types, so flows need no change.

npm fetches a prebuilt native addon (OpenCV, ZBar and ZXing bundled) for linux-x64, linux-arm64 and linuxmusl-x64. On other platforms the addon is built from source: see Installation in the reader's page.

The Rosepetal SDK engine (rp-barcode) is installed separately, from Rosepetal's private registry or with RP_BARCODE_ENGINE; the same section explains how. Without it the ZBar, ZXing and Quagga2 decoders work as usual, a rosepetal decoder block returns no results, and barcode-verifier fails every message.

Requirements ​

  • Node.js >= 18
  • Node-RED >= 1.0.0
  • Linux (Ubuntu/Debian recommended)
  • Rosepetal SDK engine rp-barcode (optional for barcode-reader, required by barcode-verifier; 0.4.0 or later for the default settings)

Nodes ​

Both nodes appear under the RP Utils category in the editor.

NodePurpose
barcode-readerRead 1D and 2D codes from an image or an array of images, with blocks that combine a decoder and a preprocessing method, run in parallel or in sequence
barcode-verifierGrade the print quality of one 1D barcode per region against ISO/IEC 15416 and check it against a GS1 symbol specification table

Decoders ​

barcode-reader runs one or more blocks. Each block pairs a decoder with a preprocessing method (Original, Histogram Equalization, Otsu Threshold or Sharpen). In parallel mode every block runs and the results are merged and deduplicated; in sequential mode the blocks run in order and stop at the first one that reads a code.

DecoderTypeReadsSpeed
ZBarC++ native1D codes, GS1 DataBar, QR Code, PDF417Fast
ZXingC++ nativeAll the 1D and 2D formats belowMedium
Quagga2JavaScript1D codesSlower
Rosepetal SDKGo engine (child process)1D codes, with a projection search for noisy, low-resolution or tilted onesFast with Effort normal (default), slower with robust

See Decoder Blocks for the options of each decoder.

Supported Formats ​

TypeFormats
1DCode 128 (GS1-128), Code 39, Code 93, EAN-13, EAN-8, UPC-A, UPC-E, Codabar, ITF, GS1 DataBar
2DQR Code, Data Matrix, PDF417, Aztec

Every decoder reads the first nine 1D formats; GS1 DataBar and the 2D formats depend on the decoder: see Decoder Format Support. barcode-verifier verifies those nine 1D formats only.

Output ​

barcode-reader writes an array of results to msg.payload (one array per image when the input is an array of images). Positions are normalized to the 0-1 range of the image:

javascript
[
  {
    format: "QRCode",
    value: "https://example.com",
    box: {
      angle: 15.2,
      center: { x: 0.5, y: 0.5 },
      size: { width: 0.2, height: 0.2 }
    },
    corners: [
      { x: 0.4, y: 0.4 },
      { x: 0.6, y: 0.4 },
      { x: 0.6, y: 0.6 },
      { x: 0.4, y: 0.6 }
    ],
    detectedBy: ["zbar_original", "zxing_histogram"]
  }
]

barcode-verifier writes an array of verification results to msg.verification, each with a status (pass, warn, fail or not_detected), the ISO/IEC 15416 grade and parameters, and a text report. See Output Format and the verifier's Output.

Guides ​

GuidePurpose
Validating the rosepetal decoderCheck on your own Node-RED that the rosepetal block reads your labels at least as well as the blocks you use today, before changing a production flow

License ​

Apache-2.0. The package uses ZBar (LGPL-2.1), ZXing-cpp (Apache-2.0), OpenCV (Apache-2.0) and Quagga2 (MIT); their license texts ship with the package in THIRD_PARTY_NOTICES.

On npm the package is @rosepetal/node-red-contrib-barcode from the first release after 1.5.2, and @rosepetal/node-red-contrib-barcode-reader up to 1.5.2.