File: processor.cpp

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 (44 lines) | stat: -rw-r--r-- 968 bytes parent folder | download | duplicates (2)
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
38
39
40
41
42
43
44
#include <iostream>
#include <zbar.h>

using namespace std;
using namespace zbar;

class MyHandler : public Image::Handler
{
    void image_callback(Image &image)
    {
	for (SymbolIterator symbol = image.symbol_begin();
	     symbol != image.symbol_end(); ++symbol)
	    cout << "decoded " << symbol->get_type_name() << " symbol "
		 << "\"" << symbol->get_data() << "\"" << endl;
    }
};

int main(int argc, char **argv)
{
    // create and initialize a Processor
    const char *device = "/dev/video0";

    if (argc > 1)
	device = argv[1];
    Processor proc(true, device);

    // configure the Processor
    proc.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);

    // setup a callback
    MyHandler my_handler;
    proc.set_handler(my_handler);

    // enable the preview window
    proc.set_visible();
    proc.set_active();

    try {
	// keep scanning until user provides key/mouse input
	proc.user_wait();
    } catch (ClosedError &e) {
    }
    return (0);
}