summaryrefslogtreecommitdiffstats
path: root/perl/examples/read_one.pl
diff options
context:
space:
mode:
Diffstat (limited to 'perl/examples/read_one.pl')
-rwxr-xr-xperl/examples/read_one.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/perl/examples/read_one.pl b/perl/examples/read_one.pl
new file mode 100755
index 0000000..d64860c
--- /dev/null
+++ b/perl/examples/read_one.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+require Barcode::ZBar;
+
+# create a Processor
+my $proc = Barcode::ZBar::Processor->new();
+
+# configure the Processor
+$proc->parse_config("enable");
+
+# initialize the Processor
+$proc->init($ARGV[0] || '/dev/video0');
+
+# enable the preview window
+$proc->set_visible();
+
+# read at least one barcode (or until window closed)
+$proc->process_one();
+
+# hide the preview window
+$proc->set_visible(0);
+
+# extract results
+foreach my $symbol ($proc->get_results()) {
+ # do something useful with results
+ print('decoded ' . $symbol->get_type() .
+ ' symbol "' . $symbol->get_data() . "\"\n");
+}