-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple.cpp
66 lines (50 loc) · 1.38 KB
/
simple.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
#include <iostream>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>
#include <math.h>
#include "libfreenect.h"
freenect_context *f_ctx;
freenect_device *f_dev;
void rgb_cb(freenect_device *dev, void *rgb, uint32_t timestamp)
{
return;
}
void depth_cb(freenect_device *dev, void *v_depth, uint32_t timestamp)
{
std::cout << "got depth\n";
return;
}
int main(int argc, char** argv)
{
if (freenect_init (&f_ctx, NULL) < 0)
{
printf ("freenect_init() failed\n");
return 1;
}
freenect_set_log_level (f_ctx, FREENECT_LOG_SPEW);
freenect_select_subdevices(f_ctx, (freenect_device_flags)(FREENECT_DEVICE_CAMERA));
int nr_devices = freenect_num_devices (f_ctx);
printf ("Number of devices found: %d\n", nr_devices);
if (nr_devices < 1)
return 1;
if (freenect_open_device (f_ctx, &f_dev, 0) < 0)
{
printf ("Could not open device\n");
return 1;
}
freenect_set_video_callback(f_dev, rgb_cb);
freenect_set_depth_callback(f_dev, depth_cb);
freenect_set_depth_mode(f_dev, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_10BIT));
std::cout << "starting depth\n";
freenect_start_depth(f_dev);
std::cout << "started depth\n";
while (freenect_process_events(f_ctx) >= 0) {
//std::cout << "handled events\n";
usleep(5);
}
freenect_close_device(f_dev);
return 0;
}