forked from smaccm/camera_demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.cpp
98 lines (74 loc) · 2.21 KB
/
demo.cpp
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// begin license header
//
// This file is part of Pixy CMUcam5 or "Pixy" for short
//
// All Pixy source code is provided under the terms of the
// GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html).
// Those wishing to use Pixy source code, software and/or
// technologies under different licensing terms should contact us at
// [email protected]. Such licensing terms are available for
// all portions of the Pixy codebase presented here.
//
// end license header
//
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <iostream>
#include "pixy.h"
#include "smaccminterpreter.hpp"
#define BLOCK_BUFFER_SIZE 25
// Pixy Block buffer //
struct Block blocks[BLOCK_BUFFER_SIZE];
void handle_SIGINT(int unused)
{
// On CTRL+C - abort! //
printf("\nBye!\n");
exit(0);
}
//defined in pixy.cpp
extern SmaccmInterpreter interpreter;
int main(int argc, char * argv[])
{
int index;
int blocks_copied;
int pixy_init_status;
// if(argc != 2){
// std::cerr << "Usage: demo <port>" << std::endl;
// return 1;
// }
// Catch CTRL+C (SIGINT) signals //
signal(SIGINT, handle_SIGINT);
printf("Hello Pixy:\n libpixyusb Version: %s\n", __LIBPIXY_VERSION__);
int32_t response;
uint32_t fourcc;
int8_t renderflags;
uint16_t width, height, sentWidth, sentHeight;
uint32_t numPixels;
//wait for client connection
interpreter.connect();
// Connect to Pixy //
pixy_init_status = pixy_init();
// Was there an error initializing pixy? //
if(!pixy_init_status == 0)
{
// Error initializing Pixy //
printf("pixy_init(): ");
pixy_error(pixy_init_status);
return pixy_init_status;
}
//this is magic. I have no idea why I need to do this but I do
printf("running prog\n");
pixy_command("runprog", 0x01, 8, END, &response, END);
printf("sent running prog\n");
//pixy_command("cam_setAWB", 0x01, 1, 0, &response, 0);
//pixy_command("cam_setMode",0x01, 1, END, &response, END);
//usleep(1000000);
int t = 0;
for(;;){
usleep(100000000);
}
}