Barcode Reading Basics

Overview

Class BarCodeReader in Aspose.BarCode for Python via .NET is the most important to implement barcode recognition for more than 60 symbologies. First, it is necessary to identify a barcode source that can be represented as a file, a stream, or a bitmap object. After that, target barcode types need to be specified using values from the DecodeType enum. By default, the library uses the DecodeType.ALL_SUPPORTED_TYPES setting that implies iterating over all supported barcode types to check for their presence in the source image. In this case, barcode scanning and recognition take much more time.

Main Recognition Parameters

Barcode reading is performed according to the following steps:

  • Determine the barcode source (image file, stream, or bitmap), e.g. set the path to a source image
  • Select target barcode types. DecodeType is set to DecodeType.ALL_SUPPORTED_TYPES by default meaning that the source image will be scanned to search for all supported barcode types; in this case, the time required to finish the barcode detection process will increase.

Class BarCodeReader contains the read_bar_codes() method that returns the result of barcode reading in an array of the BarCodeResult type.

Get Recognition Results

To load barcode recognition outputs, it is needed to call the read_bar_codes() method that gets an array of the BarCodeResult type. Moreover, the current recognition output can be accessed through the found_bar_codes property that enables fetching decoding results or the found_count property that returns the number of detected barcodes.

Recognition Abortion

Class BarCodeReader enables two ways to interrupt the recognition process if it becomes unfeasible to complete. The first one is to initialize the time_out property that defines a timeout value for the barcode reading process . By default, the TimeOut value is set to 0.

The second way is to use the abort() method. This option is used if the recognition process has been launched in the other thread. This method does not stop the entire process and returns controls immediately.