Skip to content

Barcode Reader vTool#

The Barcode Reader vTool allows you to detect various types of barcodes in images and decode them.

The Barcode Reader can detect and decode up to two barcodes in images it receives via the Image input pin. It outputs the results via the Regions and Texts output pins.

The region output contains the region in which a barcode was found. The text output is the text string encoded by the barcode.

Barcode Reader vTool

How It Works#

The Barcode Reader vTool can detect groups of barcode types. Most of these groups include several different barcode types. By selecting a group, all types contained in that group can be detected. For example, by selecting Code 39, the types Code 39 and Code 93 are detected in an image.

The following barcode type groups are supported:

  • EAN: EAN-8, EAN-8 Add-On 2, EAN-8 Add-On 5, EAN-13, EAN-13 Add-On 2, EAN-13 Add-On 5
  • UPC: UPC-A, UPC-A Add-On 2, UPC-A Add-On 5, UPC-E, UPC-E Add-On 2, UPC-E Add-On 5
  • GS1: Code-128, GS1-128, GS1 DataBar Omnidirectional, GS1 DataBar Truncated, GS1 DataBar Stacked, GS1 DataBar Stacked Omnidirectional, GS1 DataBar Limited, GS1 DataBar Expanded, GS1 DataBar Expanded Stacked
  • 2/5: 2/5 Industrial, 2/5 Interleaved
  • Code 39: Code 39, Code 93
  • Codabar: Codabar
  • MSI: MSI
  • PharmaCode: PharmaCode


  • If you open the Barcode Reader for the first time, no barcode type is set. You have to select a barcode type first. If no barcode is set, the vTool will report an error for every input image it receives via the Image input pin.
  • The MSI barcode is a non-self-checking code. Be aware that MSI codes may be found by mistake in some images.
  • The PharmaCode barcode is a code with a potentially low number of bars. Be aware that in images with a background of line-like patterns, PharmaCodes may be found by mistake.
  • The PharmaCode barcode can be read in both directions. Therefore, two strings are detected and decoded. Both strings are output at the Texts output pin. They are separated by a comma.

You can detect up to two barcodes in an image. If you know that your images only contain one barcode, configuring the Barcode Reader to only look for one barcode may save processing time. If the number of barcodes varies or is unknown, configure the Barcode Reader to look for two codes.

Detection Criteria#

For barcodes to be detected, they must meet the following criteria:

  • Minimum line width: The lines of barcodes must be at least 2 pixels wide.
  • Maximum line width: The lines of barcodes must not be wider than 8 pixels.
  • Orientation: The Barcode Reader can decode barcodes of any orientation.
  • Polarity: By default, barcodes are defined as dark-on-light patterns. If your barcodes are printed with inverse polarity, employ a pre-processing step to invert the input image.


For time-critical applications you can specify a timeout. A timeout helps in cases where the processing time varies or can't be foreseen, for example, if the image doesn't contain a barcode. Once the specified timeout is exceeded, the detection process stops and moves on to the next image.

Basler recommends setting the timeout a bit lower than the desired time limit. This is because the vTool doesn't stop the detection process immediately. Therefore, set the timeout to 70–80 % of the desired time limit.

Common Use Cases#

  • Reading barcodes: In this case, you only need to connect the Texts output pin to output the decoded strings.
  • Determining the positions of barcodes: Use the positions and sizes of the barcodes returned by the Regions output pin for subsequent processing.

Configuring the vTool#

To configure the Barcode Reader vTool:

Barcode Reader vTool Settings

  1. In the Recipe Management pane in the vTool Settings area, click Open Settings or double-click the vTool.
    The Barcode Reader dialog opens.
  2. In the Barcode Types area, select the barcode type you want to look for.
  3. In the Number of Barcodes area, select how many barcodes you want to detect.
  4. In the Timeout area, specify whether you want detection to end after a certain amount of time. If you want to specify a timeout, clear the No timeout check box and enter the desired timeout in the input field.

You can view the result of the Barcode Reader in a pin data view. Here, you can select which outputs to display.



Accepts images directly from a Camera vTool or from a vTool that outputs images, e.g., the Image Format Converter vTool.

  • Data type: Image
  • Image format: 8-bit to 16-bit mono or color images. Color images are converted internally to mono images.



Returns the text string encoded in a barcode.

  • Data type: String Array


Returns the region of every barcode found. The region is of rectangular shape. It can be used for visualization purposes or for subsequent feature extraction.

  • Data type: Region Array

Typical Predecessors#

Typical Successors#