Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in rectification parameters generation leading to wrong P #66

Open
ferreram opened this issue Mar 18, 2021 · 1 comment
Open

Bug in rectification parameters generation leading to wrong P #66

ferreram opened this issue Mar 18, 2021 · 1 comment

Comments

@ferreram
Copy link

Hi there,

I have spotted a bug in StereoCameraParameters::generateRectificationParameters() leading to wrong rectification of images (at least with the euroc_camchain config file taken from voxblox).

Starting l.655 in src/camera_parameters.cpp,

  first_.setInputCameraParameters(
      first_.getInputPtr()->resolution(),
      T.inverse() * first_.getInputPtr()->T(), first_.getInputPtr()->K(),
      first_.getInputPtr()->D(), first_.getInputPtr()->distortionModel());
  second_.setInputCameraParameters(
      second_.getInputPtr()->resolution(),
      T.inverse() * second_.getInputPtr()->T(), second_.getInputPtr()->K(),
      second_.getInputPtr()->D(), second_.getInputPtr()->distortionModel());

here T is a 4x4 homogeneous matrix defined as Eigen::Matrix4d whose top-left 3x3 block represents an SO(3) rotation matrix. The inverse of T must therefore be computed as the inverse of an SO(3) matrix :

  Eigen::Matrix4d invT;
  invT.block<3,3>(0,0) = T.block<3,3>(0,0).transpose();

  first_.setInputCameraParameters(
      first_.getInputPtr()->resolution(),
      invT * first_.getInputPtr()->T(), first_.getInputPtr()->K(),
      first_.getInputPtr()->D(), first_.getInputPtr()->distortionModel());
  second_.setInputCameraParameters(
      second_.getInputPtr()->resolution(),
      invT * second_.getInputPtr()->T(), second_.getInputPtr()->K(),
      second_.getInputPtr()->D(), second_.getInputPtr()->distortionModel());

Without this fix, the resulting P's matrices are wrong and create flipped images with non aligned along the y axis.

I am running ubuntu 18.04 (ROS melodic) and encountered this issue with both Eigen 3.3.4 and Eigen 3.3.9.

@TheFrey222
Copy link

thank you, you saved my day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants