CGR Localization
 All Classes Namespaces Files Functions Variables Macros Pages
libfreenect.h
1 /*
2  * This file is part of the OpenKinect Project. http://www.openkinect.org
3  *
4  * Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file
5  * for details.
6  *
7  * This code is licensed to you under the terms of the Apache License, version
8  * 2.0, or, at your option, the terms of the GNU General Public License,
9  * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
10  * or the following URLs:
11  * http://www.apache.org/licenses/LICENSE-2.0
12  * http://www.gnu.org/licenses/gpl-2.0.txt
13  *
14  * If you redistribute this file in source form, modified or unmodified, you
15  * may:
16  * 1) Leave this header intact and distribute it under the same terms,
17  * accompanying it with the APACHE20 and GPL20 files, or
18  * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
19  * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
20  * In all cases you must keep the copyright notice intact and include a copy
21  * of the CONTRIB file.
22  *
23  * Binary distributions must follow the binary distribution requirements of
24  * either License.
25  */
26 
27 #ifndef LIBFREENECT_H
28 #define LIBFREENECT_H
29 
30 #include <stdint.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 typedef uint16_t freenect_depth;
37 typedef uint8_t freenect_pixel;
38 
39 #define FREENECT_FRAME_W 640
40 #define FREENECT_FRAME_H 480
41 #define FREENECT_FRAME_PIX (FREENECT_FRAME_H*FREENECT_FRAME_W)
42 #define FREENECT_RGB_SIZE (FREENECT_FRAME_PIX*3)
43 #define FREENECT_BAYER_SIZE (FREENECT_FRAME_PIX)
44 #define FREENECT_DEPTH_SIZE (FREENECT_FRAME_PIX*sizeof(freenect_depth))
45 #define FREENECT_COUNTS_PER_G 819
46 
47 typedef enum {
48  FREENECT_FORMAT_RGB = 0,
49  FREENECT_FORMAT_BAYER = 1,
50 } freenect_rgb_format;
51 
52 typedef enum {
53  LED_OFF = 0,
54  LED_GREEN = 1,
55  LED_RED = 2,
56  LED_YELLOW = 3,
57  LED_BLINK_YELLOW = 4,
58  LED_BLINK_GREEN = 5,
59  LED_BLINK_RED_YELLOW = 6
60 } freenect_led_options;
61 
62 typedef enum {
63  FREENECT_FORMAT_11_BIT = 0,
64  FREENECT_FORMAT_10_BIT = 1
65 } freenect_depth_format;
66 
67 struct _freenect_context;
68 typedef struct _freenect_context freenect_context;
69 
70 struct _freenect_device;
71 typedef struct _freenect_device freenect_device;
72 
73 // usb backend specific section
74 #include <libusb.h>
75 typedef libusb_context freenect_usb_context;
76 //
77 
78 int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ctx);
79 int freenect_shutdown(freenect_context *ctx);
80 
81 int freenect_process_events(freenect_context *ctx);
82 
83 int freenect_num_devices(freenect_context *ctx);
84 int freenect_open_device(freenect_context *ctx, freenect_device **dev, int index);
85 int freenect_close_device(freenect_device *dev);
86 
87 void freenect_set_user(freenect_device *dev, void *user);
88 void *freenect_get_user(freenect_device *dev);
89 
90 typedef void (*freenect_depth_cb)(freenect_device *dev, freenect_depth *depth, uint32_t timestamp);
91 typedef void (*freenect_depth_raw_cb)(freenect_device *dev, uint8_t *depth_raw, uint32_t timestamp);
92 typedef void (*freenect_rgb_cb)(freenect_device *dev, freenect_pixel *rgb, uint32_t timestamp);
93 
94 void freenect_set_depth_callback(freenect_device *dev, freenect_depth_cb cb);
95 void freenect_set_depth_raw_callback(freenect_device *dev, freenect_depth_raw_cb cb);
96 void freenect_set_rgb_callback(freenect_device *dev, freenect_rgb_cb cb);
97 int freenect_set_rgb_format(freenect_device *dev, freenect_rgb_format fmt);
98 int freenect_set_depth_format(freenect_device *dev, freenect_depth_format fmt);
99 
100 int freenect_start_depth(freenect_device *dev);
101 int freenect_start_rgb(freenect_device *dev);
102 int freenect_stop_depth(freenect_device *dev);
103 int freenect_stop_rgb(freenect_device *dev);
104 
105 uint16_t unpack_depth(uint8_t* depth_raw, int row, int column);
106 
107 int freenect_set_tilt_in_degrees(freenect_device *dev, double angle);
108 int freenect_set_tilt_in_radians(freenect_device *dev, double angle);
109 int freenect_set_led(freenect_device *dev, freenect_led_options option);
110 
111 int freenect_get_raw_accelerometers(freenect_device *dev, int16_t* x, int16_t* y, int16_t* z);
112 int freenect_get_mks_accelerometers(freenect_device *dev, double* x, double* y, double* z);
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 #endif //
119