Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpCalibration.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Camera calibration.
32  *
33  * Authors:
34  * Eric Marchand
35  * Francois Chaumette
36  * Anthony Saunier
37  *
38  *****************************************************************************/
39 
40 
49 #ifndef vpCalibration_h
50 #define vpCalibration_h
51 
52 #include <visp3/core/vpMatrix.h>
53 #include <visp3/core/vpHomogeneousMatrix.h>
54 #include <visp3/core/vpCameraParameters.h>
55 #include <visp3/core/vpExponentialMap.h>
56 #include <visp3/core/vpMath.h>
57 #include <visp3/core/vpDisplay.h>
58 #include <visp3/core/vpImage.h>
59 #include <visp3/vision/vpCalibrationException.h>
60 #include <visp3/core/vpImagePoint.h>
61 #include <list>
62 #include <vector>
71 class VISP_EXPORT vpCalibration
72 {
73 public:
77  typedef enum{
83  } vpCalibrationMethodType ;
84 
86  vpHomogeneousMatrix cMo_dist ;
88  vpCameraParameters cam;
91  vpCameraParameters cam_dist;
93 
99 
100 public:
101  // Constructor
102  vpCalibration() ;
103  vpCalibration(const vpCalibration& c) ;
104 
105  // Destructor
106  virtual ~vpCalibration() ;
107 
108  // Add a new point in this array
109  int addPoint(double X, double Y, double Z, vpImagePoint &ip) ;
110 
111  // = operator
112  vpCalibration& operator=(const vpCalibration& twinCalibration);
113 
114  static void calibrationTsai(std::vector<vpHomogeneousMatrix> &cMo,
115  std::vector<vpHomogeneousMatrix> &rMe,
116  vpHomogeneousMatrix &eMc);
117 
119  int clearPoint() ;
120 
121  void computeStdDeviation(double &deviation, double &deviation_dist);
122  int computeCalibration(vpCalibrationMethodType method,
123  vpHomogeneousMatrix &cMo_est,
124  vpCameraParameters &cam_est,
125  bool verbose = false) ;
126  static int computeCalibrationMulti(vpCalibrationMethodType method,
127  std::vector<vpCalibration> &table_cal,
128  vpCameraParameters &cam,
129  double &globalReprojectionError,
130  bool verbose = false) ;
131 
132  static int computeCalibrationTsai(std::vector<vpCalibration> &table_cal,
133  vpHomogeneousMatrix &eMc,
134  vpHomogeneousMatrix &eMc_dist);
135  double computeStdDeviation(const vpHomogeneousMatrix &cMo_est,
136  const vpCameraParameters &camera);
137  double computeStdDeviation_dist(const vpHomogeneousMatrix &cMo,
138  const vpCameraParameters &cam);
139  int displayData(vpImage<unsigned char> &I, vpColor color=vpColor::red,
140  unsigned int thickness=1, int subsampling_factor=1) ;
141  int displayGrid(vpImage<unsigned char> &I, vpColor color=vpColor::yellow,
142  unsigned int thickness=1, int subsampling_factor=1) ;
143 
145  static double getLambda(){return gain;}
146 
148  double getResidual(void) const {return residual;}
150  double getResidual_dist(void) const {return residual_dist;}
152  unsigned int get_npt() const {return npt;}
153 
154  int init() ;
155 
156  int readData(const char *filename) ;
157  static int readGrid(const char *filename,unsigned int &n,
158  std::list<double> &oX, std::list<double> &oY, std::list<double> &oZ,
159  bool verbose = false);
160 
162  static void setLambda(const double &lambda){gain = lambda;}
163  int writeData(const char *filename) ;
164 
165 private:
166  void computePose(const vpCameraParameters &cam, vpHomogeneousMatrix &cMo);
167  void calibLagrange( vpCameraParameters &cam , vpHomogeneousMatrix &cMo) ;
168 
170  void calibVVS( vpCameraParameters &cam , vpHomogeneousMatrix &cMo,
171  bool verbose = false) ;
172 
173  static void calibVVSMulti(unsigned int nbPose, vpCalibration table_cal[],
174  vpCameraParameters &cam, bool verbose = false);
175  static void calibVVSMulti(std::vector<vpCalibration> &table_cal,
176  vpCameraParameters &cam,
177  double &globalReprojectionError, bool verbose = false) ;
178  void calibVVSWithDistortion( vpCameraParameters &cam,
179  vpHomogeneousMatrix &cMo,
180  bool verbose = false) ;
181  static void calibVVSWithDistortionMulti( unsigned int nbPose,
182  vpCalibration table_cal[],
183  vpCameraParameters &cam,
184  bool verbose = false );
185  static void calibVVSWithDistortionMulti( std::vector<vpCalibration> &table_cal,
186  vpCameraParameters &cam,
187  double &globalReprojectionError,
188  bool verbose = false);
189 
190 private:
191  unsigned int npt ;
192  std::list<double> LoX, LoY, LoZ ;
193  std::list<vpImagePoint> Lip ;
194 
195  double residual ;
196  double residual_dist ;
197 
198  static double threshold;
199  static unsigned int nbIterMax;
200  static double gain;
201 
202 } ;
203 
204 #endif
205 
206 /*
207  * Local variables:
208  * c-basic-offset: 2
209  * End:
210  */
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
static double getLambda()
Set the gain for the virtual visual servoing algorithm.
Tools for perspective camera calibration.
Definition: vpCalibration.h:71
vpHomogeneousMatrix cMo
(as a 3x4 matrix [R T])
Definition: vpCalibration.h:85
static const vpColor red
Definition: vpColor.h:163
static void setLambda(const double &lambda)
set the gain for the virtual visual servoing algorithm
Generic class defining intrinsic camera parameters.
vpHomogeneousMatrix eMc_dist
Definition: vpCalibration.h:98
unsigned int get_npt() const
get the number of points
vpHomogeneousMatrix rMe
reference coordinates (manipulator base coordinates)
Definition: vpCalibration.h:95
double getResidual_dist(void) const
get the residual for perspective projection with distortion (in pixels)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
static const vpColor yellow
Definition: vpColor.h:171
double getResidual(void) const
get the residual in pixels