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 FREENECT_INTERNAL_H
00028 #define FREENECT_INTERNAL_H
00029
00030 #include <stdint.h>
00031
00032 #include "libfreenect.h"
00033
00034 typedef void (*fnusb_iso_cb) (freenect_device * dev, uint8_t * buf, int len);
00035
00036 #include "usb_libusb10.h"
00037
00038 struct _freenect_context
00039 {
00040 freenect_loglevel log_level;
00041 freenect_log_cb log_cb;
00042 fnusb_ctx usb;
00043 };
00044
00045 #define LL_FATAL FREENECT_LOG_FATAL
00046 #define LL_ERROR FREENECT_LOG_ERROR
00047 #define LL_WARNING FREENECT_LOG_WARNING
00048 #define LL_NOTICE FREENECT_LOG_NOTICE
00049 #define LL_INFO FREENECT_LOG_INFO
00050 #define LL_DEBUG FREENECT_LOG_DEBUG
00051 #define LL_SPEW FREENECT_LOG_SPEW
00052 #define LL_FLOOD FREENECT_LOG_FLOOD
00053
00054 void fn_log (freenect_context * ctx, freenect_loglevel level, const char *fmt, ...)
00055 __attribute__ ((format (printf, 3, 4)));
00056
00057 #define FN_LOG(level, ...) fn_log(ctx, level, __VA_ARGS__)
00058
00059 #define FN_FATAL(...) FN_LOG(LL_FATAL, __VA_ARGS__)
00060 #define FN_ERROR(...) FN_LOG(LL_ERROR, __VA_ARGS__)
00061 #define FN_WARNING(...) FN_LOG(LL_WARNING, __VA_ARGS__)
00062 #define FN_NOTICE(...) FN_LOG(LL_NOTICE, __VA_ARGS__)
00063 #define FN_INFO(...) FN_LOG(LL_INFO, __VA_ARGS__)
00064 #define FN_DEBUG(...) FN_LOG(LL_DEBUG, __VA_ARGS__)
00065 #define FN_SPEW(...) FN_LOG(LL_SPEW, __VA_ARGS__)
00066 #define FN_FLOOD(...) FN_LOG(LL_FLOOD, __VA_ARGS__)
00067
00068 #define DEPTH_RAW_10_BIT_SIZE 384000
00069 #define DEPTH_RAW_11_BIT_SIZE 422400
00070 #define FRAME_H FREENECT_FRAME_H
00071 #define FRAME_W FREENECT_FRAME_W
00072 #define FRAME_PIX_DEPTH FREENECT_FRAME_PIX
00073 #define FRAME_PIX_RGB FREENECT_FRAME_PIX
00074 #define FRAME_PIX_IR (DEPTH_RAW_10_BIT_SIZE + RGB_PKTSIZE*3)
00075
00076 #define DEPTH_PKTSIZE 1760
00077 #define RGB_PKTSIZE 1920
00078
00079 #define DEPTH_PKTDSIZE (DEPTH_PKTSIZE-12)
00080 #define RGB_PKTDSIZE (RGB_PKTSIZE-12)
00081
00082 #define DEPTH_PKTS_10_BIT_PER_FRAME ((DEPTH_RAW_10_BIT_SIZE+DEPTH_PKTDSIZE-1)/DEPTH_PKTDSIZE)
00083 #define DEPTH_PKTS_11_BIT_PER_FRAME ((DEPTH_RAW_11_BIT_SIZE+DEPTH_PKTDSIZE-1)/DEPTH_PKTDSIZE)
00084 #define RGB_PKTS_PER_FRAME_RGB ((FRAME_PIX_RGB+RGB_PKTDSIZE-1)/RGB_PKTDSIZE)
00085 #define RGB_PKTS_PER_FRAME_IR ((FRAME_PIX_IR+RGB_PKTDSIZE-1)/RGB_PKTDSIZE)
00086
00087 #define MS_MAGIC_VENDOR 0x45e
00088 #define MS_MAGIC_CAMERA_PRODUCT 0x02ae
00089 #define MS_MAGIC_MOTOR_PRODUCT 0x02b0
00090
00091 typedef struct
00092 {
00093 uint8_t flag;
00094 int synced;
00095 uint8_t seq;
00096 int got_pkts;
00097 int pkt_num;
00098 int pkts_per_frame;
00099 int pkt_size;
00100 int valid_pkts;
00101 int valid_frames;
00102 uint32_t last_timestamp;
00103 uint32_t timestamp;
00104 uint8_t *buf;
00105 } packet_stream;
00106
00107 struct _freenect_device
00108 {
00109 freenect_context *parent;
00110 void *user_data;
00111
00112
00113 fnusb_dev usb_cam;
00114 fnusb_isoc_stream depth_isoc;
00115 fnusb_isoc_stream rgb_isoc;
00116
00117 freenect_depth_cb depth_cb;
00118 freenect_rgb_cb rgb_cb;
00119 freenect_ir_cb ir_cb;
00120 freenect_rgb_format rgb_format;
00121 freenect_depth_format depth_format;
00122
00123 int cam_inited;
00124 uint16_t cam_tag;
00125
00126 int depth_running;
00127 packet_stream depth_stream;
00128 uint8_t depth_raw[DEPTH_RAW_11_BIT_SIZE];
00129 uint16_t depth_frame[FRAME_PIX_DEPTH];
00130
00131 int rgb_running;
00132 packet_stream rgb_stream;
00133 uint8_t rgb_raw[FRAME_PIX_RGB];
00134 uint8_t rgb_frame[3 * FRAME_PIX_RGB];
00135
00136 int ir_running;
00137 uint8_t ir_raw[FRAME_PIX_IR];
00138 uint8_t ir_frame[3 * FRAME_PIX_IR];
00139
00140
00141
00142 fnusb_dev usb_motor;
00143 freenect_raw_device_state raw_state;
00144 };
00145
00146 struct caminit
00147 {
00148 uint16_t command;
00149 uint16_t tag;
00150 int cmdlen;
00151 int replylen;
00152 uint8_t cmddata[1024];
00153 uint8_t replydata[1024];
00154 };
00155
00156 #endif