36 #define REG_X_VAL_SCALE 256 // "fixed-point" precision for double -> int32_t conversion 38 #define S2D_PIXEL_CONST 10 39 #define S2D_CONST_OFFSET 0.375 41 #define DEPTH_SENSOR_X_RES 1280 42 #define DEPTH_MIRROR_X 0 44 #define DEPTH_MAX_METRIC_VALUE FREENECT_DEPTH_MM_MAX_VALUE 45 #define DEPTH_NO_MM_VALUE FREENECT_DEPTH_MM_NO_VALUE 46 #define DEPTH_MAX_RAW_VALUE FREENECT_DEPTH_RAW_MAX_VALUE 47 #define DEPTH_NO_RAW_VALUE FREENECT_DEPTH_RAW_NO_VALUE 49 #define DEPTH_X_OFFSET 1 50 #define DEPTH_Y_OFFSET 1 51 #define DEPTH_X_RES 640 52 #define DEPTH_Y_RES 480 71 double current_depth_in_pixels = i * pixel_size;
72 depth_to_rgb[i] = (( pixels_between_rgb_and_ir_cmos * (current_depth_in_pixels - reference_distance_in_pixels) / current_depth_in_pixels) +
S2D_CONST_OFFSET) *
REG_X_VAL_SCALE;
93 frame[0] = (r0<<3) | (r1>>5);
94 frame[1] = ((r1<<6) | (r2>>2) ) & baseMask;
95 frame[2] = ((r2<<9) | (r3<<1) | (r4>>7) ) & baseMask;
96 frame[3] = ((r4<<4) | (r5>>4) ) & baseMask;
97 frame[4] = ((r5<<7) | (r6>>1) ) & baseMask;
98 frame[5] = ((r6<<10) | (r7<<2) | (r8>>6) ) & baseMask;
99 frame[6] = ((r8<<5) | (r9>>3) ) & baseMask;
100 frame[7] = ((r9<<8) | (r10) ) & baseMask;
108 size_t i, *wipe = (
size_t*)output_mm;
120 if (source_index == 8) {
141 if (nx >= DEPTH_X_RES)
continue;
144 uint32_t target_index = (
DEPTH_MIRROR_X ? ((ny + 1) * DEPTH_X_RES - nx - 1) : (ny * DEPTH_X_RES + nx)) - target_offset;
151 output_mm[target_index] = metric_depth;
153 #ifdef DENSE_REGISTRATION 155 if ((nx > 0) && (ny > 0)) {
156 output_mm[target_index -
DEPTH_X_RES ] = metric_depth;
157 output_mm[target_index - DEPTH_X_RES - 1] = metric_depth;
158 output_mm[target_index - 1] = metric_depth;
160 output_mm[target_index -
DEPTH_X_RES] = metric_depth;
162 output_mm[target_index - 1] = metric_depth;
180 if (source_index == 8) {
225 for (row = 0 ; row < resolution_y ; row++) {
229 dXdX0 += dYdXdX0 >> 8;
233 dYdX0 += dYdYdX0 >> 8;
238 dXdY0 += dYdXdY0 >> 8;
242 dYdY0 += dYdYdY0 >> 8;
245 int64_t coldXdXdY0 = dXdXdY0, coldXdY0 = dXdY0, coldY0 = dY0;
247 int64_t coldXdXdX0 = dXdXdX0, coldXdX0 = dXdX0, coldX0 = dX0;
249 for (col = 0 ; col < resolution_x ; col++, tOffs++) {
250 reg_x_table[tOffs] = coldX0 * (1.0/(1<<17));
251 reg_y_table[tOffs] = coldY0 * (1.0/(1<<17));
253 coldX0 += coldXdX0 >> 6;
254 coldXdX0 += coldXdXdX0 >> 8;
257 coldY0 += coldXdY0 >> 6;
258 coldXdY0 += coldXdXdY0 >> 8;
280 if ((new_x < 0) || (new_y < 0) || (new_x >= DEPTH_X_RES) || (new_y >= DEPTH_Y_RES))
284 registration_table[index][1] = new_y;
327 double factor = 2 * ref_pix_size * wz / ref_distance;
FN_INTERNAL int freenect_init_registration(freenect_device *dev)
freenect_zero_plane_info zero_plane_info
freenect_registration registration
void freenect_camera_to_world(freenect_device *dev, int cx, int cy, int wz, double *wx, double *wy)
camera -> world coordinate helper function
int freenect_destroy_registration(freenect_registration *reg)
static void freenect_init_depth_to_rgb(int32_t *depth_to_rgb, freenect_zero_plane_info *zpi)
fill the table of horizontal shift values for metric depth -> RGB conversion
freenect_reg_info reg_info
static void complete_tables(freenect_registration *reg)
Compute registration tables.
static void freenect_init_registration_table(int32_t(*registration_table)[2], freenect_reg_info *reg_info)
static double pixel_size_factor
internal Kinect zero plane data
uint16_t * raw_to_mm_shift
static void freenect_create_dxdy_tables(double *reg_x_table, double *reg_y_table, int32_t resolution_x, int32_t resolution_y, freenect_reg_info *regdata)
#define DEPTH_MAX_RAW_VALUE
static void unpack_8_pixels(uint8_t *raw, uint16_t *frame)
#define DEPTH_SENSOR_X_RES
int32_t(* registration_table)[2]
int32_t * depth_to_rgb_shift
all data needed for depth->RGB mapping
#define DEPTH_MAX_METRIC_VALUE
static double parameter_coefficient
static double shift_scale
#define DEPTH_NO_RAW_VALUE
static uint16_t freenect_raw_to_mm(uint16_t raw, freenect_registration *reg)
convert raw shift value to metric depth (in mm)
freenect_reg_pad_info reg_pad_info
float reference_pixel_size
FN_INTERNAL int freenect_apply_depth_to_mm(freenect_device *dev, uint8_t *input_packed, uint16_t *output_mm)
#define DEPTH_NO_MM_VALUE
freenect_registration freenect_copy_registration(freenect_device *dev)
FN_INTERNAL int freenect_apply_registration(freenect_device *dev, uint8_t *input_packed, uint16_t *output_mm)