コード例 #1
0
//\fn void ExtrinsicParam::getCameraPointFrom3d(Eigen::Vector3d realP, double &x, double &y, double &z);
///\brief This function computes the coordinates of a 3D point from the real landmark to the one of the camera.
///\param realP Value of the 3D point in the real landmark.
///\param x Value of the 3D point in the camera landmark and on the x axis.
///\param y Value of the 3D point in the camera landmark and on the y axis.
///\param z Value of the distance between the camera and the 3D point (the scale).
void ExtrinsicParam::getCameraPointFrom3d(Eigen::Vector3d realP, double &x, double &y, double &z)
{
  Eigen::Vector4d real;
  real << realP,
          1;
  double fx = K(0,0), fy = K(1,1), cx = K(0,2), cy = K(1,2);  
  Eigen::Vector3d imgP;
  Eigen::MatrixXd Rt;
  Rt.resize(3,4);
  Rt << rotation,translation;
  imgP.noalias() = K*Rt*real;
  z = imgP(2);
  imgP.noalias() = imgP/imgP(2);
  Eigen::Vector3d temp = imgP;
  temp(0) = (temp(0)-cx)/fx;
  temp(1) = (temp(1)-cy)/fy;
  temp.noalias() = distortPoint(temp);
  x = temp(0);
  y = temp(1);
}