-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest5.py
More file actions
executable file
·37 lines (32 loc) · 782 Bytes
/
test5.py
File metadata and controls
executable file
·37 lines (32 loc) · 782 Bytes
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
30
31
32
33
34
35
36
37
#!/usr/bin/python
from sys import argv
#import zebra
import zbar
import os
# 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)
# setup a callback
def my_handler(proc, image, closure):
# extract results
for symbol in image:
if not symbol.count:
# do something useful with results
os.system("beep")
#print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data
print symbol.data
proc.set_data_handler(my_handler)
# enable the preview window
proc.visible = True
# initiate scanning
proc.active = True
try:
proc.user_wait()
except zbar.WindowClosed:
pass