libfreenect  0.1.2
libfreenect.h
Go to the documentation of this file.
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 #pragma once
28 
29 #include <stdint.h>
30 
31 /* We need struct timeval */
32 #ifdef _WIN32
33 #include <winsock.h>
34 #else
35 #include <sys/time.h>
36 #endif
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #define FREENECT_COUNTS_PER_G 819
44 #define FREENECT_DEPTH_MM_MAX_VALUE 10000
46 #define FREENECT_DEPTH_MM_NO_VALUE 0
48 #define FREENECT_DEPTH_RAW_MAX_VALUE 2048
50 #define FREENECT_DEPTH_RAW_NO_VALUE 2047
52 
58 typedef enum {
63 
68 {
69  struct freenect_device_attributes *next; // Next device in the linked list
70  const char* camera_serial; // Serial number of camera or audio subdevice
71 };
72 
77 typedef enum {
83 
86 typedef enum {
94  FREENECT_VIDEO_DUMMY = 2147483647,
96 
99 typedef enum {
106  FREENECT_DEPTH_DUMMY = 2147483647,
108 
110 typedef enum {
111  // values written to the CMOS register
115  // arbitrary bitfields to support flag combination
118  FREENECT_NEAR_MODE = 1 << 18, // K4W only
119 } freenect_flag;
120 
122 typedef enum {
126 
130 typedef struct {
131  uint32_t reserved;
133  union {
134  int32_t dummy;
137  };
138  int32_t bytes;
139  int16_t width;
140  int16_t height;
143  int8_t framerate;
144  int8_t is_valid;
146 
149 typedef enum {
150  LED_OFF = 0,
151  LED_GREEN = 1,
152  LED_RED = 2,
155  // 5 is same as 4, LED blink Green
158 
159 
161 typedef enum {
166 
168 typedef struct {
169  int16_t accelerometer_x;
170  int16_t accelerometer_y;
171  int16_t accelerometer_z;
172  int8_t tilt_angle;
175 
176 struct _freenect_context;
177 typedef struct _freenect_context freenect_context;
179 struct _freenect_device;
180 typedef struct _freenect_device freenect_device;
182 // usb backend specific section
183 typedef void freenect_usb_context;
184 //
185 
187 #ifndef _WIN32
188  #define FREENECTAPI
189 #else
190 
191  #ifdef __cplusplus
192  #define FREENECTAPI extern "C" __declspec(dllexport)
193  #else
194  // this is required when building from a Win32 port of gcc without being
195  // forced to compile all of the library files (.c) with g++...
196  #define FREENECTAPI __declspec(dllexport)
197  #endif
198 #endif
199 
201 typedef enum {
211 
221 FREENECTAPI int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ctx);
222 
231 
233 typedef void (*freenect_log_cb)(freenect_context *dev, freenect_loglevel level, const char *msg);
234 
242 
251 
260 
271 FREENECTAPI int freenect_process_events_timeout(freenect_context *ctx, struct timeval* timeout);
272 
282 
293 
300 
310 
322 
331 
344 
356 FREENECTAPI int freenect_open_device_by_camera_serial(freenect_context *ctx, freenect_device **dev, const char* camera_serial);
357 
366 
374 FREENECTAPI void freenect_set_user(freenect_device *dev, void *user);
375 
384 
386 typedef void (*freenect_depth_cb)(freenect_device *dev, void *depth, uint32_t timestamp);
388 typedef void (*freenect_video_cb)(freenect_device *dev, void *video, uint32_t timestamp);
390 typedef void (*freenect_chunk_cb)(void *buffer, void *pkt_data, int pkt_num, int datalen, void *user_data);
391 
392 
400 
408 
416 
424 
436 
448 
457 
466 
475 
484 
495 
504 
513 
526 FREENECTAPI int freenect_set_tilt_degs(freenect_device *dev, double angle);
527 
537 
548 
560 FREENECTAPI void freenect_get_mks_accel(freenect_raw_tilt_state *state, double* x, double* y, double* z);
561 
568 
578 
588 
599 
613 
620 
630 
640 
651 
662 
672 
681 
690 FREENECTAPI int freenect_set_ir_brightness(freenect_device *dev, uint16_t brightness);
691 
699 FREENECTAPI void freenect_set_fw_address_nui(freenect_context * ctx, unsigned char * fw_ptr, unsigned int num_bytes);
700 
708 FREENECTAPI void freenect_set_fw_address_k4w(freenect_context * ctx, unsigned char * fw_ptr, unsigned int num_bytes);
709 
710 
711 #ifdef __cplusplus
712 }
713 #endif