summaryrefslogtreecommitdiffstats
path: root/python/examples/read_one.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/examples/read_one.py')
-rw-r--r--python/examples/read_one.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/python/examples/read_one.py b/python/examples/read_one.py
new file mode 100644
index 0000000..7a18c99
--- /dev/null
+++ b/python/examples/read_one.py
@@ -0,0 +1,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)