ViSP  2.9.0
vpCalibration.h
1 /****************************************************************************
2  *
3  * $Id: vpCalibration.h 4663 2014-02-14 10:32:11Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Camera calibration.
36  *
37  * Authors:
38  * Eric Marchand
39  * Francois Chaumette
40  * Anthony Saunier
41  *
42  *****************************************************************************/
43 
44 
53 #ifndef vpCalibration_h
54 #define vpCalibration_h
55 
56 #include <visp/vpMatrix.h>
57 #include <visp/vpHomogeneousMatrix.h>
58 #include <visp/vpCameraParameters.h>
59 #include <visp/vpExponentialMap.h>
60 #include <visp/vpMath.h>
61 #include <visp/vpDisplay.h>
62 #include <visp/vpImage.h>
63 #include <visp/vpCalibrationException.h>
64 #include <visp/vpImagePoint.h>
65 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
66 # include <visp/vpList.h>
67 #endif
68 #include <list>
69 #include <vector>
78 class VISP_EXPORT vpCalibration
79 {
80 public:
84  typedef enum{
90  } vpCalibrationMethodType ;
91 
93  vpHomogeneousMatrix cMo_dist ;
95  vpCameraParameters cam;
98  vpCameraParameters cam_dist;
100 
103  vpHomogeneousMatrix eMc;
106 
107 public:
108  // Constructor
109  vpCalibration() ;
110  vpCalibration(const vpCalibration& c) ;
111 
112  // Destructor
113  virtual ~vpCalibration() ;
114 
115  // Add a new point in this array
116  int addPoint(double X, double Y, double Z, vpImagePoint &ip) ;
117 
118  // = operator
119  vpCalibration& operator=(const vpCalibration& twinCalibration);
120 
121  static void calibrationTsai(std::vector<vpHomogeneousMatrix> &cMo,
122  std::vector<vpHomogeneousMatrix> &rMe,
123  vpHomogeneousMatrix &eMc);
124 
126  int clearPoint() ;
127 
128  void computeStdDeviation(double &deviation, double &deviation_dist);
129  int computeCalibration(vpCalibrationMethodType method,
130  vpHomogeneousMatrix &cMo_est,
131  vpCameraParameters &cam_est,
132  bool verbose = false) ;
133  static int computeCalibrationMulti(vpCalibrationMethodType method,
134  std::vector<vpCalibration> &table_cal,
135  vpCameraParameters &cam,
136  double &globalReprojectionError,
137  bool verbose = false) ;
138 
139  static int computeCalibrationTsai(std::vector<vpCalibration> &table_cal,
140  vpHomogeneousMatrix &eMc,
141  vpHomogeneousMatrix &eMc_dist);
142  double computeStdDeviation(const vpHomogeneousMatrix &cMo_est,
143  const vpCameraParameters &camera);
144  double computeStdDeviation_dist(const vpHomogeneousMatrix &cMo,
145  const vpCameraParameters &cam);
146  int displayData(vpImage<unsigned char> &I, vpColor color=vpColor::red,
147  unsigned int thickness=1) ;
148  int displayGrid(vpImage<unsigned char> &I, vpColor color=vpColor::yellow,
149  unsigned int thickness=1) ;
150 
152  static double getLambda(){return gain;}
153 
155  double getResidual(void) const {return residual;}
157  double getResidual_dist(void) const {return residual_dist;}
159  unsigned int get_npt() const {return npt;}
160 
161  int init() ;
162 
163  int readData(const char *filename) ;
164  static int readGrid(const char *filename,unsigned int &n,
165  std::list<double> &oX, std::list<double> &oY, std::list<double> &oZ,
166  bool verbose = false);
167 
169  static void setLambda(const double &lambda){gain = lambda;}
170  int writeData(const char *filename) ;
171 
172 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
173 
176  static void calibrationTsai(unsigned int nbPose, vpHomogeneousMatrix cMo[],
177  vpHomogeneousMatrix rMe[],
178  vpHomogeneousMatrix &eMc);
179  static int computeCalibrationMulti(vpCalibrationMethodType method,unsigned int nbPose,
180  vpCalibration table_cal[],
181  vpCameraParameters &cam,
182  bool verbose = false) ;
183  vp_deprecated static int computeCalibrationTsai(unsigned int nbPose,
184  vpCalibration table_cal[],
185  vpHomogeneousMatrix &eMc,
186  vpHomogeneousMatrix &eMc_dist);
187  vp_deprecated static int readGrid(const char *filename,unsigned int &n,
189  bool verbose = false);
190 #endif
191 
192 private:
193  void computePose(const vpCameraParameters &cam, vpHomogeneousMatrix &cMo);
194  void calibLagrange( vpCameraParameters &cam , vpHomogeneousMatrix &cMo) ;
195 
197  void calibVVS( vpCameraParameters &cam , vpHomogeneousMatrix &cMo,
198  bool verbose = false) ;
199 
200  static void calibVVSMulti(unsigned int nbPose, vpCalibration table_cal[],
201  vpCameraParameters &cam, bool verbose = false);
202  static void calibVVSMulti(std::vector<vpCalibration> &table_cal,
203  vpCameraParameters &cam,
204  double &globalReprojectionError, bool verbose = false) ;
205  void calibVVSWithDistortion( vpCameraParameters &cam,
206  vpHomogeneousMatrix &cMo,
207  bool verbose = false) ;
208  static void calibVVSWithDistortionMulti( unsigned int nbPose,
209  vpCalibration table_cal[],
210  vpCameraParameters &cam,
211  bool verbose = false );
212  static void calibVVSWithDistortionMulti( std::vector<vpCalibration> &table_cal,
213  vpCameraParameters &cam,
214  double &globalReprojectionError,
215  bool verbose = false);
216 
217 private:
218  unsigned int npt ;
219  std::list<double> LoX, LoY, LoZ ;
220  std::list<vpImagePoint> Lip ;
221 
222  double residual ;
223  double residual_dist ;
224 
225  static double threshold;
226  static unsigned int nbIterMax;
227  static double gain;
228 
229 } ;
230 
231 #endif
232 
233 /*
234  * Local variables:
235  * c-basic-offset: 2
236  * End:
237  */
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
Provide simple list management.
Definition: vpList.h:113
Class to define colors available for display functionnalities.
Definition: vpColor.h:125
static double getLambda()
Set the gain for the virtual visual servoing algorithm.
Tools for perspective camera calibration.
Definition: vpCalibration.h:78
vpHomogeneousMatrix cMo
(as a 3x4 matrix [R T])
Definition: vpCalibration.h:92
static const vpColor red
Definition: vpColor.h:167
static void setLambda(const double &lambda)
set the gain for the virtual visual servoing algorithm
Generic class defining intrinsic camera parameters.
vpHomogeneousMatrix eMc_dist
unsigned int get_npt() const
get the number of points
vpHomogeneousMatrix rMe
reference coordinates (manipulator base coordinates)
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:92
static const vpColor yellow
Definition: vpColor.h:175
double getResidual(void) const
get the residual in pixels