File: read_one.pl

package info (click to toggle)
zbar 0.10%2Bdoc-4
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,856 kB
  • ctags: 2,903
  • sloc: ansic: 21,641; sh: 10,745; cpp: 1,997; python: 774; xml: 473; perl: 289; makefile: 189
file content (29 lines) | stat: -rwxr-xr-x 636 bytes parent folder | download | duplicates (13)
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 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");
}