demo_reader.py 371 B

12345678910111213
  1. import sys, zxingcpp
  2. from PIL import Image
  3. img = Image.open(sys.argv[1])
  4. barcodes = zxingcpp.read_barcodes(img)
  5. for barcode in barcodes:
  6. print('Found barcode:'
  7. f'\n Text: "{barcode.text}"'
  8. f'\n Format: {barcode.format}'
  9. f'\n Content: {barcode.content_type}'
  10. f'\n Position: {barcode.position}')
  11. if len(barcodes) == 0:
  12. print("Could not find any barcode.")