File: read_one.py

package info (click to toggle)
zbar 0.23.93-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,324 kB
  • sloc: ansic: 33,723; objc: 5,735; cpp: 3,289; python: 1,144; java: 818; sh: 720; xml: 716; perl: 491; makefile: 362
file content (29 lines) | stat: -rw-r--r-- 586 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/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)