Some of the examples and test code don't work with python 2.7 and PIL. Modernize them by running 2to3 and fixing PIL manually. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
30 lines
586 B
Python
30 lines
586 B
Python
#!/usr/bin/env python
|
|
from sys import argv
|
|
import zbar
|
|
|
|
# create a Processor
|
|
proc = zbar.Processor()
|
|
|
|
# configure the Processor
|
|
proc.parse_config('enable')
|
|
|
|
# initialize the Processor
|
|
device = '/dev/video0'
|
|
if len(argv) > 1:
|
|
device = argv[1]
|
|
proc.init(device)
|
|
|
|
# enable the preview window
|
|
proc.visible = True
|
|
|
|
# read at least one barcode (or until window closed)
|
|
proc.process_one()
|
|
|
|
# hide the preview window
|
|
proc.visible = False
|
|
|
|
# extract results
|
|
for symbol in proc.results:
|
|
# do something useful with results
|
|
print('decoded', symbol.type, 'symbol', '"%s"' % symbol.data)
|