-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv4ltest.c
More file actions
72 lines (63 loc) · 1.73 KB
/
v4ltest.c
File metadata and controls
72 lines (63 loc) · 1.73 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright 2005 Andrew Rice
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Email: acr31@cam.ac.uk
*/
#include <stdio.h>
#include <stdlib.h>
#include "options.h"
#include "v4l.h"
#include "recognise.h"
#include "codegen_util.h"
#include "image.h"
#include <string.h>
int main(int argc,char** argv) {
unsigned char decoded[PAYLOAD_SIZE_BYTES] = {0};
int read_order[EDGE_CELLS*EDGE_CELLS];
struct v4l_handle* vhandle;
unsigned char* data;
int i;
int counter = 0;
if (argc != 2) {
printf("%s [video device]\n",argv[0]);
exit(-1);
}
populate_read_order(read_order);
vhandle = v4l_open(argv[1]);
if (vhandle == 0) {
printf("Failed to open and initialise Video4Linux\n");
exit(-1);
}
while (++counter < 2) {
data = v4l_next(vhandle);
if (data == 0) {
printf("Failed to grab image\n");
}
else {
if (process_image(data,decoded,read_order)) {
printf("Decoded:\t");
for(i=0;i<PAYLOAD_SIZE_BYTES;++i) {
printf("%.2X ",decoded[i]);
}
printf("\n");
}
}
}
v4l_close(vhandle);
return 1;
}