Skip to content

sparkfish/pdf417decoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pdf417decoder

Image of a PDF417 barcode

pdf417decoder is a pure Python library for decoding PDF417 barcodes.

Reader is capable of Error Detection and Correction according to the standards for PDF417 which you can read about here ISO/IEC 15438:2006 or download an older version of the PDF this website.

Installation

Use the package manager pip to install pdf417decoder.

pip install pdf417decoder

Usage

from PIL import Image as PIL
from pdf417decoder import PDF417Decoder

image = PIL.open("barcode.png")
decoder = PDF417Decoder(image)

if (decoder.decode() > 0):
    decoded = decoder.barcode_data_index_to_string(0)

Testing Results

This library was tested using pdf417gen to create random barcodes and blurred with OpenCV to test error correction. PyTest is used with several test images to show the libraries capability to decode barcodes in the following test cases.

  • Binary data
  • Multiple barcodes
  • Upside down barcode
  • Rotated barcode
  • Error Corrections: Corrupted data due to blurred barcode
  • Error Corrections: Missing data due marks concealing barcode
  • Character type transitions (Upper, Lower, Mixed and Punctuation)

Roadmap

  • Initial port of C# to Python
  • Create tests for functionality
  • Create fuzzy testing of decoder
  • Decode from PIL.Image
  • Decode from Numpy Array
  • Convert THRESH_OTSU image processing to use original algorithm written in C# or alternative
  • Performance testing and optimizations

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

CPOL

This project is a derivative of code licensed under the Code Project Open License (CPOL). The Code Project Open License (CPOL) is intended to provide developers who choose to share their code with a license that protects them and provides users of their code with a clear statement regarding how the code can be used.

Credits

Source code is a port of a C# Library created and maintained by Uzi Granot. PDF417 Barcode Decoder .NET Class Library and Two Demo Apps