Skip to content

Commit b0891b7

Browse files
committed
registration: allow mapping unpacked 11bit depth to mm
This adds an alternative utility api for mapping depth values that have already been unpacked into 16 bit values (i.e. the FREENECT_DEPTH_11BIT format) into MM (i.e. the FREENECT_DEPTH_MM format). The plan is to use this in fakenect for mapping recorded _DEPTH_11BIT data into _DEPTH_MM if that's what the application requires. Signed-off-by: Robert Bragg <[email protected]>
1 parent 9629e4a commit b0891b7

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/registration.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,22 @@ FN_INTERNAL int freenect_apply_depth_to_mm(freenect_device* dev, uint8_t* input_
190190
return 0;
191191
}
192192

193+
// Same as freenect_apply_depth_to_mm, but don't need to unpack 11 bit depth values
194+
FN_INTERNAL int freenect_apply_depth_unpacked_to_mm(freenect_device* dev, uint16_t* input, uint16_t* output_mm)
195+
{
196+
freenect_registration* reg = &(dev->registration);
197+
uint32_t x,y;
198+
for (y = 0; y < DEPTH_Y_RES; y++) {
199+
for (x = 0; x < DEPTH_X_RES; x++) {
200+
// get the value at the current depth pixel, convert to millimeters
201+
uint32_t buf_index = y * DEPTH_X_RES + x;
202+
uint16_t metric_depth = reg->raw_to_mm_shift[input[buf_index]];
203+
output_mm[buf_index] = metric_depth < DEPTH_MAX_METRIC_VALUE ? metric_depth : DEPTH_MAX_METRIC_VALUE;
204+
}
205+
}
206+
return 0;
207+
}
208+
193209
// create temporary x/y shift tables
194210
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 )
195211
{

src/registration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@
3232
int freenect_init_registration(freenect_device* dev);
3333
int freenect_apply_registration(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm);
3434
int freenect_apply_depth_to_mm(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm);
35+
int freenect_apply_depth_unpacked_to_mm(freenect_device* dev, uint16_t* input, uint16_t* output_mm);

0 commit comments

Comments
 (0)