Advertisement
metalx1000

Read PDF417 Bar Codes with Python

Nov 23rd, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. #!/usr/bin/python3
  2. # Dependencies
  3. # sudo apt install python3-zxing-cpp python3-opencv
  4.  
  5. import zxingcpp
  6. import cv2
  7.  
  8. def decode_pdf417(image_path):
  9.     img = cv2.imread(image_path)
  10.     barcodes = zxingcpp.read_barcodes(img)
  11.  
  12.     for barcode in barcodes:
  13.         if barcode.format == zxingcpp.BarcodeFormat.PDF417:
  14.             print("Found PDF417 barcode:")
  15.             print("Text:", barcode.text)
  16.             print("Position:", barcode.position)
  17.  
  18. if __name__ == "__main__":
  19.     decode_pdf417("/tmp/odf417.jpeg")
  20.  
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement