Skip to content

Commit

Permalink
Actually, the camera_to_world scale factor should just be 2.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
zarvox committed Oct 29, 2011
1 parent aed0262 commit 73a22af
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/registration.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,14 @@ void freenect_camera_to_world(freenect_device* dev, int cx, int cy, int wz, doub
{
double ref_pix_size = dev->registration.zero_plane_info.reference_pixel_size;
double ref_distance = dev->registration.zero_plane_info.reference_distance;
double factor = ref_pix_size * wz / ref_distance;
// We multiply cx and cy by these factors because they come from a 640x480 image,
// but the zero plane pixel size is for a 1280x1024 image.
*wx = (double)(cx - DEPTH_X_RES/2) * factor * (1280./640.);
*wy = (double)(cy - DEPTH_Y_RES/2) * factor * (1024./480.);
// However, the 640x480 image is produced by cropping the 1280x1024 image
// to 1280x960 and then scaling by .5, so aspect ratio is maintained, and
// we should simply multiply by two in each dimension.
double factor = 2 * ref_pix_size * wz / ref_distance;
*wx = (double)(cx - DEPTH_X_RES/2) * factor;
*wy = (double)(cy - DEPTH_Y_RES/2) * factor;
}

/// Allocate and fill registration tables
Expand Down

0 comments on commit 73a22af

Please sign in to comment.