libfreenect
0.1.2
|
00001 /* 00002 * This file is part of the OpenKinect Project. http://www.openkinect.org 00003 * 00004 * Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file 00005 * for details. 00006 * 00007 * This code is licensed to you under the terms of the Apache License, version 00008 * 2.0, or, at your option, the terms of the GNU General Public License, 00009 * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, 00010 * or the following URLs: 00011 * http://www.apache.org/licenses/LICENSE-2.0 00012 * http://www.gnu.org/licenses/gpl-2.0.txt 00013 * 00014 * If you redistribute this file in source form, modified or unmodified, you 00015 * may: 00016 * 1) Leave this header intact and distribute it under the same terms, 00017 * accompanying it with the APACHE20 and GPL20 files, or 00018 * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or 00019 * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file 00020 * In all cases you must keep the copyright notice intact and include a copy 00021 * of the CONTRIB file. 00022 * 00023 * Binary distributions must follow the binary distribution requirements of 00024 * either License. 00025 */ 00026 00027 #ifndef LIBFREENECT_H 00028 #define LIBFREENECT_H 00029 00030 #include <stdint.h> 00031 00032 /* We need struct timeval */ 00033 #ifdef _WIN32 00034 #include <winsock.h> 00035 #else 00036 #include <sys/time.h> 00037 #endif 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 00043 #define FREENECT_COUNTS_PER_G 819 00045 00046 #define FREENECT_DEPTH_MM_MAX_VALUE 10000 00047 00048 #define FREENECT_DEPTH_MM_NO_VALUE 0 00049 00050 #define FREENECT_DEPTH_RAW_MAX_VALUE 2048 00051 00052 #define FREENECT_DEPTH_RAW_NO_VALUE 2047 00053 00059 typedef enum { 00060 FREENECT_DEVICE_MOTOR = 0x01, 00061 FREENECT_DEVICE_CAMERA = 0x02, 00062 FREENECT_DEVICE_AUDIO = 0x04, 00063 } freenect_device_flags; 00064 00068 struct freenect_device_attributes; 00069 struct freenect_device_attributes { 00070 struct freenect_device_attributes *next; 00071 const char* camera_serial; 00072 }; 00073 00078 typedef enum { 00079 FREENECT_RESOLUTION_LOW = 0, 00080 FREENECT_RESOLUTION_MEDIUM = 1, 00081 FREENECT_RESOLUTION_HIGH = 2, 00082 FREENECT_RESOLUTION_DUMMY = 2147483647, 00083 } freenect_resolution; 00084 00087 typedef enum { 00088 FREENECT_VIDEO_RGB = 0, 00089 FREENECT_VIDEO_BAYER = 1, 00090 FREENECT_VIDEO_IR_8BIT = 2, 00091 FREENECT_VIDEO_IR_10BIT = 3, 00092 FREENECT_VIDEO_IR_10BIT_PACKED = 4, 00093 FREENECT_VIDEO_YUV_RGB = 5, 00094 FREENECT_VIDEO_YUV_RAW = 6, 00095 FREENECT_VIDEO_DUMMY = 2147483647, 00096 } freenect_video_format; 00097 00100 typedef enum { 00101 FREENECT_DEPTH_11BIT = 0, 00102 FREENECT_DEPTH_10BIT = 1, 00103 FREENECT_DEPTH_11BIT_PACKED = 2, 00104 FREENECT_DEPTH_10BIT_PACKED = 3, 00105 FREENECT_DEPTH_REGISTERED = 4, 00106 FREENECT_DEPTH_MM = 5, 00107 FREENECT_DEPTH_DUMMY = 2147483647, 00108 } freenect_depth_format; 00109 00113 typedef struct { 00114 uint32_t reserved; 00115 freenect_resolution resolution; 00116 union { 00117 int32_t dummy; 00118 freenect_video_format video_format; 00119 freenect_depth_format depth_format; 00120 }; 00121 int32_t bytes; 00122 int16_t width; 00123 int16_t height; 00124 int8_t data_bits_per_pixel; 00125 int8_t padding_bits_per_pixel; 00126 int8_t framerate; 00127 int8_t is_valid; 00128 } freenect_frame_mode; 00129 00132 typedef enum { 00133 LED_OFF = 0, 00134 LED_GREEN = 1, 00135 LED_RED = 2, 00136 LED_YELLOW = 3, 00137 LED_BLINK_GREEN = 4, 00138 // 5 is same as 4, LED blink Green 00139 LED_BLINK_RED_YELLOW = 6, 00140 } freenect_led_options; 00141 00142 00144 typedef enum { 00145 TILT_STATUS_STOPPED = 0x00, 00146 TILT_STATUS_LIMIT = 0x01, 00147 TILT_STATUS_MOVING = 0x04, 00148 } freenect_tilt_status_code; 00149 00151 typedef struct { 00152 int16_t accelerometer_x; 00153 int16_t accelerometer_y; 00154 int16_t accelerometer_z; 00155 int8_t tilt_angle; 00156 freenect_tilt_status_code tilt_status; 00157 } freenect_raw_tilt_state; 00158 00159 struct _freenect_context; 00160 typedef struct _freenect_context freenect_context; 00162 struct _freenect_device; 00163 typedef struct _freenect_device freenect_device; 00165 // usb backend specific section 00166 typedef void freenect_usb_context; 00167 // 00168 00170 #ifndef _WIN32 00171 #define FREENECTAPI 00172 #else 00173 00174 #ifdef __cplusplus 00175 #define FREENECTAPI extern "C" __declspec(dllexport) 00176 #else 00177 // this is required when building from a Win32 port of gcc without being 00178 // forced to compile all of the library files (.c) with g++... 00179 #define FREENECTAPI __declspec(dllexport) 00180 #endif 00181 #endif 00182 00184 typedef enum { 00185 FREENECT_LOG_FATAL = 0, 00186 FREENECT_LOG_ERROR, 00187 FREENECT_LOG_WARNING, 00188 FREENECT_LOG_NOTICE, 00189 FREENECT_LOG_INFO, 00190 FREENECT_LOG_DEBUG, 00191 FREENECT_LOG_SPEW, 00192 FREENECT_LOG_FLOOD, 00193 } freenect_loglevel; 00194 00204 FREENECTAPI int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ctx); 00205 00213 FREENECTAPI int freenect_shutdown(freenect_context *ctx); 00214 00216 typedef void (*freenect_log_cb)(freenect_context *dev, freenect_loglevel level, const char *msg); 00217 00224 FREENECTAPI void freenect_set_log_level(freenect_context *ctx, freenect_loglevel level); 00225 00233 FREENECTAPI void freenect_set_log_callback(freenect_context *ctx, freenect_log_cb cb); 00234 00242 FREENECTAPI int freenect_process_events(freenect_context *ctx); 00243 00254 FREENECTAPI int freenect_process_events_timeout(freenect_context *ctx, struct timeval* timeout); 00255 00264 FREENECTAPI int freenect_num_devices(freenect_context *ctx); 00265 00275 FREENECTAPI int freenect_list_device_attributes(freenect_context *ctx, struct freenect_device_attributes** attribute_list); 00276 00282 FREENECTAPI void freenect_free_device_attributes(struct freenect_device_attributes* attribute_list); 00283 00292 FREENECTAPI int freenect_supported_subdevices(void); 00293 00304 FREENECTAPI void freenect_select_subdevices(freenect_context *ctx, freenect_device_flags subdevs); 00305 00317 FREENECTAPI int freenect_open_device(freenect_context *ctx, freenect_device **dev, int index); 00318 00330 FREENECTAPI int freenect_open_device_by_camera_serial(freenect_context *ctx, freenect_device **dev, const char* camera_serial); 00331 00339 FREENECTAPI int freenect_close_device(freenect_device *dev); 00340 00348 FREENECTAPI void freenect_set_user(freenect_device *dev, void *user); 00349 00357 FREENECTAPI void *freenect_get_user(freenect_device *dev); 00358 00360 typedef void (*freenect_depth_cb)(freenect_device *dev, void *depth, uint32_t timestamp); 00362 typedef void (*freenect_video_cb)(freenect_device *dev, void *video, uint32_t timestamp); 00363 00370 FREENECTAPI void freenect_set_depth_callback(freenect_device *dev, freenect_depth_cb cb); 00371 00378 FREENECTAPI void freenect_set_video_callback(freenect_device *dev, freenect_video_cb cb); 00379 00390 FREENECTAPI int freenect_set_depth_buffer(freenect_device *dev, void *buf); 00391 00402 FREENECTAPI int freenect_set_video_buffer(freenect_device *dev, void *buf); 00403 00411 FREENECTAPI int freenect_start_depth(freenect_device *dev); 00412 00420 FREENECTAPI int freenect_start_video(freenect_device *dev); 00421 00429 FREENECTAPI int freenect_stop_depth(freenect_device *dev); 00430 00438 FREENECTAPI int freenect_stop_video(freenect_device *dev); 00439 00449 FREENECTAPI int freenect_update_tilt_state(freenect_device *dev); 00450 00458 FREENECTAPI freenect_raw_tilt_state* freenect_get_tilt_state(freenect_device *dev); 00459 00467 FREENECTAPI double freenect_get_tilt_degs(freenect_raw_tilt_state *state); 00468 00481 FREENECTAPI int freenect_set_tilt_degs(freenect_device *dev, double angle); 00482 00491 FREENECTAPI freenect_tilt_status_code freenect_get_tilt_status(freenect_raw_tilt_state *state); 00492 00502 FREENECTAPI int freenect_set_led(freenect_device *dev, freenect_led_options option); 00503 00515 FREENECTAPI void freenect_get_mks_accel(freenect_raw_tilt_state *state, double* x, double* y, double* z); 00516 00522 FREENECTAPI int freenect_get_video_mode_count(); 00523 00532 FREENECTAPI freenect_frame_mode freenect_get_video_mode(int mode_num); 00533 00542 FREENECTAPI freenect_frame_mode freenect_get_current_video_mode(freenect_device *dev); 00543 00553 FREENECTAPI freenect_frame_mode freenect_find_video_mode(freenect_resolution res, freenect_video_format fmt); 00554 00567 FREENECTAPI int freenect_set_video_mode(freenect_device* dev, freenect_frame_mode mode); 00568 00574 FREENECTAPI int freenect_get_depth_mode_count(); 00575 00584 FREENECTAPI freenect_frame_mode freenect_get_depth_mode(int mode_num); 00585 00594 FREENECTAPI freenect_frame_mode freenect_get_current_depth_mode(freenect_device *dev); 00595 00605 FREENECTAPI freenect_frame_mode freenect_find_depth_mode(freenect_resolution res, freenect_depth_format fmt); 00606 00616 FREENECTAPI int freenect_set_depth_mode(freenect_device* dev, const freenect_frame_mode mode); 00617 00618 #ifdef __cplusplus 00619 } 00620 #endif 00621 00622 #endif // 00623