Exemplo n.º 1
0
/*!
  Compute the multi-images calibration according to the desired method using many poses.

  \param method : Method used to estimate the camera parameters.
  \param table_cal : Vector of vpCalibration.
  \param cam_est : Estimated intrinsic camera parameters.
  \param globalReprojectionError : Global reprojection error or global residual.
  \param verbose : Set at true if information about the residual at each loop
  of the algorithm is hoped.

  \return 0 if the computation was managed succeed.
*/
int vpCalibration::computeCalibrationMulti(vpCalibrationMethodType method,
                                           std::vector<vpCalibration> &table_cal,
                                           vpCameraParameters& cam_est,
                                           double &globalReprojectionError,
                                           bool verbose)
{
  try{
    unsigned int nbPose = (unsigned int) table_cal.size();
    for(unsigned int i=0;i<nbPose;i++){
      if(table_cal[i].get_npt()>3)
        table_cal[i].computePose(cam_est,table_cal[i].cMo);
    }
    switch (method) {
    case CALIB_LAGRANGE : {
      if(nbPose > 1){
        std::cout << "this calibration method is not available in" << std::endl
                  << "vpCalibration::computeCalibrationMulti()" << std::endl;
        return -1 ;
      }
      else {
        table_cal[0].calibLagrange(cam_est,table_cal[0].cMo);
        table_cal[0].cam = cam_est ;
        table_cal[0].cam_dist = cam_est ;
        table_cal[0].cMo_dist = table_cal[0].cMo ;
      }
      break;
    }
    case CALIB_LAGRANGE_VIRTUAL_VS :
    case CALIB_LAGRANGE_VIRTUAL_VS_DIST : {
      if(nbPose > 1){
        std::cout << "this calibration method is not available in" << std::endl
                  << "vpCalibration::computeCalibrationMulti()" << std::endl
                  << "with several images." << std::endl;
        return -1 ;
      }
      else {
        table_cal[0].calibLagrange(cam_est,table_cal[0].cMo);
        table_cal[0].cam = cam_est ;
        table_cal[0].cam_dist = cam_est ;
        table_cal[0].cMo_dist = table_cal[0].cMo ;
      }
      calibVVSMulti(table_cal, cam_est, globalReprojectionError, verbose);
      break ;
    }
    case CALIB_VIRTUAL_VS:
    case CALIB_VIRTUAL_VS_DIST: {
      calibVVSMulti(table_cal, cam_est, globalReprojectionError, verbose);
      break ;
    }
    }
    //Print camera parameters
    if(verbose){
      //       std::cout << "Camera parameters without distortion :" << std::endl;
      cam_est.printParameters();
    }

    switch (method)
    {
    case CALIB_LAGRANGE :
    case CALIB_LAGRANGE_VIRTUAL_VS :
    case CALIB_VIRTUAL_VS:
      verbose = false ;
      break;
    case CALIB_LAGRANGE_VIRTUAL_VS_DIST :
    case CALIB_VIRTUAL_VS_DIST:
      {
        if(verbose)
          std::cout << "Compute camera parameters with distortion"<<std::endl;

        calibVVSWithDistortionMulti(table_cal, cam_est, globalReprojectionError, verbose);
      }
      break ;
    }
    //Print camera parameters
    if(verbose){
      //       std::cout << "Camera parameters without distortion :" << std::endl;
      table_cal[0].cam.printParameters();
      //       std::cout << "Camera parameters with distortion:" << std::endl;
      cam_est.printParameters();
      std::cout<<std::endl;
    }
    return 0 ;
  }
  catch(...){ throw; }
}
Exemplo n.º 2
0
/*!
  Compute the calibration according to the desired method using one pose.

  \param method : Method that will be used to estimate the parameters.
  \param cMo_est : estimated homogeneous matrix that defines the pose.
  \param cam_est : estimated intrinsic camera parameters.
  \param verbose : set at true if information about the residual at each loop
  of the algorithm is hoped.

  \return 0 if the calibration computation succeed.
*/
int vpCalibration::computeCalibration(vpCalibrationMethodType method,
                                      vpHomogeneousMatrix &cMo_est,
                                      vpCameraParameters &cam_est,
                                      bool verbose)
{
  try{
    computePose(cam_est,cMo_est);
    switch (method)
    {
    case CALIB_LAGRANGE :
    case CALIB_LAGRANGE_VIRTUAL_VS :
      {
        calibLagrange(cam_est, cMo_est);
      }
      break;
    case CALIB_VIRTUAL_VS:
    case CALIB_VIRTUAL_VS_DIST:
    case CALIB_LAGRANGE_VIRTUAL_VS_DIST:
    default:
      break;
    }

    switch (method)
    {
    case CALIB_VIRTUAL_VS:
    case CALIB_VIRTUAL_VS_DIST:
    case CALIB_LAGRANGE_VIRTUAL_VS:
    case CALIB_LAGRANGE_VIRTUAL_VS_DIST:
      {
        if (verbose){std::cout << "start calibration without distortion"<< std::endl;}
        calibVVS(cam_est, cMo_est, verbose);
      }
      break ;
    case CALIB_LAGRANGE:
    default:
      break;
    }
    this->cMo = cMo_est;
    this->cMo_dist = cMo_est;

    //Print camera parameters
    if(verbose){
      //       std::cout << "Camera parameters without distortion :" << std::endl;
      cam_est.printParameters();
    }

    this->cam = cam_est;

    switch (method)
    {
    case CALIB_VIRTUAL_VS_DIST:
    case CALIB_LAGRANGE_VIRTUAL_VS_DIST:
      {
        if (verbose){std::cout << "start calibration with distortion"<< std::endl;}
        calibVVSWithDistortion(cam_est, cMo_est, verbose);
      }
      break ;
    case CALIB_LAGRANGE:
    case CALIB_VIRTUAL_VS:
    case CALIB_LAGRANGE_VIRTUAL_VS:
    default:
      break;
    }
    //Print camera parameters
    if(verbose){
      //       std::cout << "Camera parameters without distortion :" << std::endl;
      this->cam.printParameters();
      //       std::cout << "Camera parameters with distortion :" << std::endl;
      cam_est.printParameters();
    }

    this->cam_dist = cam_est ;

    this->cMo_dist = cMo_est;
    return 0 ;
  }
  catch(...){
    throw;
  }
}