Start and stop characters are defined as part of linear barcode (1D barcode) standard. However, you may suffer from some nonstandard 1D barcode symbologies in which the start and stop characters are somehow changed. In this article, I will take Code39 as an example, demonstrating how to decode nonstandard 1D barcodes using Dynamsoft Barcode Reader SDK.
- Python 3.x
Python Barcode SDK Installation
Dynamsoft Barcode Reader SDK only supports Python 3.x.
pip install dbr
Nonstandard 1D Barcode Recognition
For comparison, I prepared three Code39 images with different start and stop characters.
Standard Code39 Symbology (*)
Nonstandard Code39 Symbology (+)
Nonstandard Code39 Symbology (-)
Here is the code snippet for decoding a standard 1D barcode image:
You need to get a free trial license before running the code.
If you run the code with nonstandard 1D barcode symbologies, there is no result. According to the online documentation, the nonstandard barcode is defined as an extended format in EnumBarcodeFormat_2.
Therefore, you need to make a little bit change to the code above:
In addition, you have to set the start and stop characters related to the barcode type. A simple way is to load a JSON-formatted parameter template file:
For nonstandard barcodes, you just need to modify the following part:
"StandardFormat": "BF_CODE_39","HeadModuleRatio": "131113131","TailModuleRatio": "131113131"
- StandardFormat: the barcode symbology
- HeadModuleRatio: the start character
- TailModuleRatio: the stop character
By referencing the Code39 character table, “
131113131" represents "
+" and "
131111313" represents "
Now you can create a custom template file and load it in Python code:
Run my Python code to read the standard and nonstandard Code39 barcodes:
Originally published at https://www.dynamsoft.com on June 12, 2020.