File: demo_reader.py

package info (click to toggle)
zxing-cpp 2.3.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,832 kB
  • sloc: cpp: 32,803; ansic: 18,360; php: 1,156; python: 215; makefile: 25; sh: 3
file content (13 lines) | stat: -rw-r--r-- 371 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
import sys, zxingcpp
from PIL import Image

img = Image.open(sys.argv[1])
barcodes = zxingcpp.read_barcodes(img)
for barcode in barcodes:
	print('Found barcode:'
		f'\n Text:    "{barcode.text}"'
		f'\n Format:   {barcode.format}'
		f'\n Content:  {barcode.content_type}'
		f'\n Position: {barcode.position}')
if len(barcodes) == 0:
	print("Could not find any barcode.")