Skip to content

Commit 73a22af

Browse files
committed
Actually, the camera_to_world scale factor should just be 2.
The 640x480 image is actually the result of cropping the 1280x1024 image down to 1280x960 and then scaling by .5, so aspect ratio is preserved, and we should scale x and y by exactly 2. Thanks to Kyle McDonald for paying attention to detail and pointing this out. Signed-off-by: Drew Fisher <[email protected]>
1 parent aed0262 commit 73a22af

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/registration.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,14 @@ void freenect_camera_to_world(freenect_device* dev, int cx, int cy, int wz, doub
319319
{
320320
double ref_pix_size = dev->registration.zero_plane_info.reference_pixel_size;
321321
double ref_distance = dev->registration.zero_plane_info.reference_distance;
322-
double factor = ref_pix_size * wz / ref_distance;
323322
// We multiply cx and cy by these factors because they come from a 640x480 image,
324323
// but the zero plane pixel size is for a 1280x1024 image.
325-
*wx = (double)(cx - DEPTH_X_RES/2) * factor * (1280./640.);
326-
*wy = (double)(cy - DEPTH_Y_RES/2) * factor * (1024./480.);
324+
// However, the 640x480 image is produced by cropping the 1280x1024 image
325+
// to 1280x960 and then scaling by .5, so aspect ratio is maintained, and
326+
// we should simply multiply by two in each dimension.
327+
double factor = 2 * ref_pix_size * wz / ref_distance;
328+
*wx = (double)(cx - DEPTH_X_RES/2) * factor;
329+
*wy = (double)(cy - DEPTH_Y_RES/2) * factor;
327330
}
328331

329332
/// Allocate and fill registration tables

0 commit comments

Comments
 (0)