Exemplo n.º 1
0
/*!
  Create a vpColVector of a projected point.

  \param p : Point to project.
  \param v : Resulting vector.
  \param K : Camera parameters.
*/
void
vpMbScanLine::createVectorFromPoint(const vpPoint &p, vpColVector &v, const vpCameraParameters &K)
{
    v = vpColVector(3);

    v[0] = p.get_X() * K.get_px() + K.get_u0() * p.get_Z();
    v[1] = p.get_Y() * K.get_py() + K.get_v0() * p.get_Z();
    v[2] = p.get_Z();
}
Exemplo n.º 2
0
  sensor_msgs::CameraInfo toSensorMsgsCameraInfo(vpCameraParameters& cam_info, unsigned int cam_image_width, unsigned int cam_image_height ){
      sensor_msgs::CameraInfo ret;

      std::vector<double> D(5);
      D[0]=cam_info.get_kdu();
      D[1] = D[2] = D[3] = D[4] = 0.;
      ret.D = D;
      ret.P.assign(0.);
      ret.K.assign(0.);
      ret.R.assign(0.);

      ret.R[0] = 1.;
      ret.R[1 * 3 + 1] = 1.;
      ret.R[2 * 3 + 2] = 1.;

      ret.P[0 * 4 + 0] = cam_info.get_px();
      ret.P[1 * 4 + 1] = cam_info.get_py();
      ret.P[0 * 4 + 2] = cam_info.get_u0();
      ret.P[1 * 4 + 2] = cam_info.get_v0();
      ret.P[2 * 4 + 2] = 1;


      ret.K[0 * 3 + 0] = cam_info.get_px();
      ret.K[1 * 3 + 1] = cam_info.get_py();
      ret.K[0 * 3 + 2] = cam_info.get_u0();
      ret.K[1 * 3 + 2] = cam_info.get_v0();
      ret.K[2 * 3 + 2] = 1;

      ret.distortion_model = "plumb_bob";
      ret.binning_x = 0;
      ret.binning_y = 0;
      ret.width = cam_image_width;
      ret.height = cam_image_height;

      return ret;
  }
Exemplo n.º 3
0
/*!
  Compute and return the standard deviation expressed in pixel
  for pose matrix and camera intrinsic parameters for model without distortion.
  \param cMo_est : the matrix that defines the pose to be tested.
  \param camera : camera intrinsic parameters to be tested.
  \return the standard deviation by point of the error in pixel .
*/
double vpCalibration::computeStdDeviation(const vpHomogeneousMatrix& cMo_est,
                                          const vpCameraParameters& camera)
{
  double residual_ = 0 ;

  std::list<double>::const_iterator it_LoX = LoX.begin();
  std::list<double>::const_iterator it_LoY = LoY.begin();
  std::list<double>::const_iterator it_LoZ = LoZ.begin();
  std::list<vpImagePoint>::const_iterator it_Lip = Lip.begin();

  double u0 = camera.get_u0() ;
  double v0 = camera.get_v0() ;
  double px = camera.get_px() ;
  double py = camera.get_py() ;
  vpImagePoint ip;

  for (unsigned int i =0 ; i < npt ; i++)
  {
    double oX = *it_LoX;
    double oY = *it_LoY;
    double oZ = *it_LoZ;

    double cX = oX*cMo_est[0][0]+oY*cMo_est[0][1]+oZ*cMo_est[0][2] + cMo_est[0][3];
    double cY = oX*cMo_est[1][0]+oY*cMo_est[1][1]+oZ*cMo_est[1][2] + cMo_est[1][3];
    double cZ = oX*cMo_est[2][0]+oY*cMo_est[2][1]+oZ*cMo_est[2][2] + cMo_est[2][3];

    double x = cX/cZ ;
    double y = cY/cZ ;

    ip = *it_Lip;
    double u = ip.get_u() ;
    double v = ip.get_v() ;

    double xp = u0 + x*px;
    double yp = v0 + y*py;

    residual_ += (vpMath::sqr(xp-u) + vpMath::sqr(yp-v))  ;

    ++it_LoX;
    ++it_LoY;
    ++it_LoZ;
    ++it_Lip;
  }
  this->residual = residual_ ;
  return sqrt(residual_/npt) ;
}
Exemplo n.º 4
0
/*!
  Computes the coordinates of the point corresponding to the intersection
  between a circle and a line.

  \warning This functions assumes changeFrame() and projection() have already been called.

  \sa changeFrame(), projection()

  \param circle : Circle to consider for the intersection.
  \param cam : Camera parameters that have to be used for the intersection computation.
  \param rho : The rho parameter of the line.
  \param theta : The theta parameter of the line.
  \param i : resulting i-coordinate of the intersection point.
  \param j : resulting j-coordinate of the intersection point.
*/
void
vpCircle::computeIntersectionPoint(const vpCircle &circle, const vpCameraParameters &cam, const double &rho, const double &theta, double &i, double &j)
{
   // This was taken from the code of art-v1. (from the artCylinder class)
   double px = cam.get_px() ;
   double py = cam.get_py() ;
   double u0 = cam.get_u0() ;
   double v0 = cam.get_v0() ;

   double mu11 = circle.p[3];
   double mu02 = circle.p[4];
   double mu20 = circle.p[2];
   double Xg = u0 + circle.p[0]*px;
   double Yg = v0 + circle.p[1]*py;

   // Find Intersection between line and ellipse in the image.

   // Optimised calculation for X
   double stheta = sin(theta);
   double ctheta = cos(theta);
   double sctheta = stheta*ctheta;
   double m11yg = mu11*Yg;
   double ctheta2 = vpMath::sqr(ctheta);
   double m02xg = mu02*Xg;
   double m11stheta = mu11*stheta;
   j = ((mu11*Xg*sctheta-mu20*Yg*sctheta+mu20*rho*ctheta
   -m11yg+m11yg*ctheta2+m02xg-m02xg*ctheta2+
   m11stheta*rho)/(mu20*ctheta2+2.0*m11stheta*ctheta
       +mu02-mu02*ctheta2));
   //Optimised calculation for Y
   double rhom02 = rho*mu02;
   double sctheta2 = stheta*ctheta2;
   double ctheta3 = ctheta2*ctheta;
   i = (-(-rho*mu11*stheta*ctheta-rhom02+rhom02*ctheta2
    +mu11*Xg*sctheta2-mu20*Yg*sctheta2-ctheta*mu11*Yg
    +ctheta3*mu11*Yg+ctheta*mu02*Xg-ctheta3*mu02*Xg)/
        (mu20*ctheta2+2.0*mu11*stheta*ctheta+mu02-
   mu02*ctheta2)/stheta);
}
Exemplo n.º 5
0
/*!
  Compute and return the standard deviation expressed in pixel
  for pose matrix and camera intrinsic parameters with pixel to meter model.
  \param cMo_est : the matrix that defines the pose to be tested.
  \param camera : camera intrinsic parameters to be tested.
  \return the standard deviation by point of the error in pixel .
*/
double vpCalibration::computeStdDeviation_dist(const vpHomogeneousMatrix& cMo_est,
                                               const vpCameraParameters& camera)
{
  double residual_ = 0 ;

  std::list<double>::const_iterator it_LoX = LoX.begin();
  std::list<double>::const_iterator it_LoY = LoY.begin();
  std::list<double>::const_iterator it_LoZ = LoZ.begin();
  std::list<vpImagePoint>::const_iterator it_Lip = Lip.begin();

  double u0 = camera.get_u0() ;
  double v0 = camera.get_v0() ;
  double px = camera.get_px() ;
  double py = camera.get_py() ;
  double kud = camera.get_kud() ;
  double kdu = camera.get_kdu() ;

  double inv_px = 1/px;
  double inv_py = 1/px;
  vpImagePoint ip;

  for (unsigned int i =0 ; i < npt ; i++)
  {
    double oX = *it_LoX;
    double oY = *it_LoY;
    double oZ = *it_LoZ;

    double cX = oX*cMo_est[0][0]+oY*cMo_est[0][1]+oZ*cMo_est[0][2] + cMo_est[0][3];
    double cY = oX*cMo_est[1][0]+oY*cMo_est[1][1]+oZ*cMo_est[1][2] + cMo_est[1][3];
    double cZ = oX*cMo_est[2][0]+oY*cMo_est[2][1]+oZ*cMo_est[2][2] + cMo_est[2][3];

    double x = cX/cZ ;
    double y = cY/cZ ;

    ip = *it_Lip;
    double u = ip.get_u() ;
    double v = ip.get_v() ;

    double r2ud = 1+kud*(vpMath::sqr(x)+vpMath::sqr(y)) ;

    double xp = u0 + x*px*r2ud;
    double yp = v0 + y*py*r2ud;

    residual_ += (vpMath::sqr(xp-u) + vpMath::sqr(yp-v))  ;

    double r2du = (vpMath::sqr((u-u0)*inv_px)+vpMath::sqr((v-v0)*inv_py)) ;

    xp = u0 + x*px - kdu*(u-u0)*r2du;
    yp = v0 + y*py - kdu*(v-v0)*r2du;

    residual_ += (vpMath::sqr(xp-u) + vpMath::sqr(yp-v))  ;
    ++it_LoX;
    ++it_LoY;
    ++it_LoZ;
    ++it_Lip;
  }
  residual_ /=2;

  this->residual_dist = residual_;
  return sqrt(residual_/npt) ;
}