uzh-rpg / rpg_monocular_pose_estimator

A monocular pose estimation system based on infrared LEDs
GNU General Public License v3.0
134 stars 78 forks source link

Why the P is not identity? #3

Closed limhyon closed 9 years ago

limhyon commented 10 years ago

D: [-0.358561237166698, 0.149312912580924, 0.000484551782515636, -0.000200189442379448, 0.0] K: [615.652408400557, 0.0, 362.655454167686, 0.0, 616.760184718123, 256.67210750994, 0.0, 0.0, 1.0] R: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0] P: [525.978149414062, 0.0, 357.619310580667, 0.0, 0.0, 579.796447753906, 258.377118195804, 0.0, 0.0, 0.0, 1.0, 0.0]

Hi, In your example bag file, why the P is not identity? (or it should have same number as K I think) Usually, only K is effective, however, the P is not similar with K.

For example, http://wiki.ros.org/camera_calibration/Tutorials/MonocularCalibration, the P is identity.

vgrabe commented 10 years ago

Hi Lim,

it is great to hear from you, it has been quite some time!

That wiki page seams to be outdated - the calibration tool does provide an estimate for P now. And yes, P would be equal to K if you moved that "scale" slider all the way to the right. In that case, you have black borders but use the entire image. However, when using the default settings (slider all the way to the left), the camera zooms in to avoid black borders and P starts to differantiate from K. Therefore, in particular for lenses with a wide FoV, P will not equal K unless black image borders are desired. If you choose to let ROS rectify an image for you, it will respect P and widly ignore K.

Let me know if that helps.

Another note: The version of the ros calibration tool that is currently available on the repository for Ubuntu 14.04. is quite broken. However, all major bugs have been fixed in the source code version.

Cheers, Volker

Fromandto commented 9 years ago

Hello Volker,

I've been trying to figure this out the whole day, thank god there's already an issue about it.

The difference between P and K in function LEDDetector::distortPoints() confuses me still.

————————————————————————————————————————

const cv::Point2d &p = src[i]; double x = (p.x - cx_P) / fx_P; double y = (p.y - cy_P) / fy_P; double xCorrected, yCorrected;

// Correct distortion
{
  double r2 = x * x + y * y;

  // Radial distortion
  xCorrected = x * (1. + k1 * r2 + k2 * r2 * r2 + k3 * r2 * r2 * r2);
  yCorrected = y * (1. + k1 * r2 + k2 * r2 * r2 + k3 * r2 * r2 * r2);

  // Tangential distortion
  xCorrected = xCorrected + (2. * p1 * x * y + p2 * (r2 + 2. * x * x));
  yCorrected = yCorrected + (p1 * (r2 + 2. * y * y) + 2. * p2 * x * y);
}

// Project coordinates onto image plane
{
  xCorrected = xCorrected * fx_K + cx_K;
  yCorrected = yCorrected * fy_K + cy_K;
}
dst.push_back(cv::Point2d(xCorrected, yCorrected));

————————————————————————————————————————

In the codes above, P is used for unprojecting but K for projecting.

Why ?

If the difference between P and K is just 'black borders', I think we should use same matrix for unprojection and projection.

Or say, what will happen (what will become inaccurate) if I use the parameters in K for both unprojecting and projecting?

THX in advance

eliasm commented 9 years ago

The projection matrix is indeed not required. We solved this here https://github.com/uzh-rpg/rpg_monocular_pose_estimator/pull/7.

mfaessle commented 9 years ago

Thanks @eliasm for looking into this.