0

I use opencv and openNi to calibrate the kinect and my HD camera,with the method in RGBDCaptureKinect, It use the freenect_camera_to_world to

the origin code:

// camera -> world coordinate helper function
void freenect_camera_to_world(freenect_device* dev, int cx, int cy, int wz, double* wx, double* wy)
{
    double ref_pix_size = dev->registration.zero_plane_info.reference_pixel_size;
    double ref_distance = dev->registration.zero_plane_info.reference_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.

// 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;
}

I write the freenect_camera_to_world function myself , but I have no idea is it right?

void freenect_camera_to_world(int cx,int cy,int wz, double *wx,double *wy)
{
double ref_pix_size = 0.1042; //how can I know these two value for my kienct?
double ref_distance = 120.0; 

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;
}

1、how can I know these two value for my kienct?ref_pix_size & ref_distance

2、and is it a standard for "the zero plane pixel size is for a 1280x1024 image."???

GanLiting
  • 21
  • 3

1 Answers1

1

ref_pix_size & ref_distance are contained in the hardware of each Kinect and they differ from Kinect to Kinect since the Depth cameras are differently aligned with respect to the Video cameras due to tiny differences when glued on the hardware board at the factory. But you don't have to worry about that if you read them directly from :

dev->registration.zero_plane_info.reference_pixel_size;
dev->registration.zero_plane_info.reference_distance;

You can certainly compute them after a stereo-calibration of your kinect : http://wiki.ros.org/kinect_calibration/technical But you don't need to calibrate it manually because freenect has pretty good default parameter to align color and depth images using the FREENECT_DEPTH_REGISTERED.

doizuc
  • 408
  • 5
  • 11