00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef LIBFREENECT_H
00028 #define LIBFREENECT_H
00029
00030 #include <stdint.h>
00031
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035
00036 typedef uint16_t freenect_depth;
00037 typedef uint8_t freenect_packed_depth;
00038 typedef uint8_t freenect_pixel;
00039 typedef uint16_t freenect_pixel_ir;
00040
00041 #define FREENECT_FRAME_W 640
00042 #define FREENECT_FRAME_H 480
00043 #define FREENECT_FRAME_PIX (FREENECT_FRAME_H*FREENECT_FRAME_W)
00044 #define FREENECT_RGB_SIZE (FREENECT_FRAME_PIX*3)
00045 #define FREENECT_BAYER_SIZE (FREENECT_FRAME_PIX)
00046 #define FREENECT_DEPTH_SIZE (FREENECT_FRAME_PIX*sizeof(freenect_depth))
00047 #define FREENECT_COUNTS_PER_G 819
00048
00049 typedef enum {
00050 FREENECT_FORMAT_RGB = 0,
00051 FREENECT_FORMAT_BAYER = 1,
00052 FREENECT_FORMAT_IR = 2,
00053 } freenect_rgb_format;
00054
00055 typedef enum {
00056 LED_OFF = 0,
00057 LED_GREEN = 1,
00058 LED_RED = 2,
00059 LED_YELLOW = 3,
00060 LED_BLINK_YELLOW = 4,
00061 LED_BLINK_GREEN = 5,
00062 LED_BLINK_RED_YELLOW = 6
00063 } freenect_led_options;
00064
00065 typedef enum {
00066 FREENECT_FORMAT_11_BIT = 0,
00067 FREENECT_FORMAT_10_BIT = 1,
00068 FREENECT_FORMAT_PACKED_11_BIT = 2,
00069 FREENECT_FORMAT_PACKED_10_BIT = 3,
00070 } freenect_depth_format;
00071
00072 typedef enum {
00073 TILT_STATUS_STOPPED = 0x00,
00074 TILT_STATUS_LIMIT = 0x01,
00075 TILT_STATUS_MOVING = 0x04
00076 } freenect_tilt_status_code;
00077
00078 typedef struct {
00079 int16_t accelerometer_x;
00080 int16_t accelerometer_y;
00081 int16_t accelerometer_z;
00082 int8_t tilt_angle;
00083 freenect_tilt_status_code tilt_status;
00084 } freenect_raw_device_state;
00085
00086 struct _freenect_context;
00087 typedef struct _freenect_context freenect_context;
00088
00089 struct _freenect_device;
00090 typedef struct _freenect_device freenect_device;
00091
00092
00093 #include <libusb-1.0/libusb.h>
00094 typedef libusb_context freenect_usb_context;
00095
00096
00097 typedef enum {
00098 FREENECT_LOG_FATAL = 0,
00099 FREENECT_LOG_ERROR,
00100 FREENECT_LOG_WARNING,
00101 FREENECT_LOG_NOTICE,
00102 FREENECT_LOG_INFO,
00103 FREENECT_LOG_DEBUG,
00104 FREENECT_LOG_SPEW,
00105 FREENECT_LOG_FLOOD,
00106 } freenect_loglevel;
00107
00108 int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ctx);
00109 int freenect_shutdown(freenect_context *ctx);
00110
00111 typedef void (*freenect_log_cb)(freenect_context *dev, freenect_loglevel level, const char *msg);
00112
00113 void freenect_set_log_level(freenect_context *ctx, freenect_loglevel level);
00114 void freenect_set_log_callback(freenect_context *ctx, freenect_log_cb cb);
00115
00116 int freenect_process_events(freenect_context *ctx);
00117
00118 int freenect_num_devices(freenect_context *ctx);
00119 int freenect_open_device(freenect_context *ctx, freenect_device **dev, int index);
00120 int freenect_close_device(freenect_device *dev);
00121
00122 void freenect_set_user(freenect_device *dev, void *user);
00123 void *freenect_get_user(freenect_device *dev);
00124
00125 typedef void (*freenect_depth_cb)(freenect_device *dev, void *depth, uint32_t timestamp);
00126 typedef void (*freenect_rgb_cb)(freenect_device *dev, freenect_pixel *rgb, uint32_t timestamp);
00127 typedef void (*freenect_ir_cb)(freenect_device *dev, freenect_pixel_ir *rgb, uint32_t timestamp);
00128
00129 void freenect_set_depth_callback(freenect_device *dev, freenect_depth_cb cb);
00130 void freenect_set_rgb_callback(freenect_device *dev, freenect_rgb_cb cb);
00131 void freenect_set_ir_callback(freenect_device *dev, freenect_ir_cb cb);
00132 int freenect_set_rgb_format(freenect_device *dev, freenect_rgb_format fmt);
00133 int freenect_set_depth_format(freenect_device *dev, freenect_depth_format fmt);
00134
00135 int freenect_start_depth (freenect_device *dev);
00136 int freenect_start_rgb (freenect_device *dev);
00137 int freenect_start_ir (freenect_device *dev);
00138 int freenect_stop_depth (freenect_device *dev);
00139 int freenect_stop_rgb (freenect_device *dev);
00140 int freenect_stop_ir (freenect_device *dev);
00141
00142 int freenect_set_tilt_degs(freenect_device *dev, double angle);
00143 int freenect_set_led(freenect_device *dev, freenect_led_options option);
00144
00145 int freenect_update_device_state(freenect_device *dev);
00146 freenect_raw_device_state* freenect_get_device_state(freenect_device *dev);
00147 void freenect_get_mks_accel(freenect_raw_device_state *state, double* x, double* y, double* z);
00148 double freenect_get_tilt_degs(freenect_raw_device_state *state);
00149
00150 #ifdef __cplusplus
00151 }
00152 #endif
00153
00154 #endif //
00155