ViSP  2.8.0
vpCalibration.h
1 /****************************************************************************
2  *
3  * $Id: vpCalibration.h 4317 2013-07-17 09:40:17Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 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  int init() ;
109 
111  int clearPoint() ;
112  // Add a new point in this array
113  int addPoint(double X, double Y, double Z, vpImagePoint &ip) ;
114 
116  vpCalibration() ;
117 
119  virtual ~vpCalibration() ;
121  void operator=(vpCalibration& twinCalibration );
122 
124  double getResidual(void) const {return residual;}
126  double getResidual_dist(void) const {return residual_dist;}
128  unsigned int get_npt() const {return npt;}
129 
130  static void calibrationTsai(std::vector<vpHomogeneousMatrix> &cMo,
131  std::vector<vpHomogeneousMatrix> &rMe,
132  vpHomogeneousMatrix &eMc);
133 
134  void computeStdDeviation(double &deviation, double &deviation_dist);
135  int computeCalibration(vpCalibrationMethodType method,
136  vpHomogeneousMatrix &cMo,
137  vpCameraParameters &cam,
138  bool verbose = false) ;
139  static int computeCalibrationMulti(vpCalibrationMethodType method,
140  std::vector<vpCalibration> &table_cal,
141  vpCameraParameters &cam,
142  double &globalReprojectionError,
143  bool verbose = false) ;
144 
145  static int computeCalibrationTsai(std::vector<vpCalibration> &table_cal,
146  vpHomogeneousMatrix &eMc,
147  vpHomogeneousMatrix &eMc_dist);
148  double computeStdDeviation(vpHomogeneousMatrix &cMo,
149  vpCameraParameters &cam);
150  double computeStdDeviation_dist(vpHomogeneousMatrix &cMo,
151  vpCameraParameters &cam);
152  int displayData(vpImage<unsigned char> &I, vpColor color=vpColor::red,
153  unsigned int thickness=1) ;
154  int displayGrid(vpImage<unsigned char> &I, vpColor color=vpColor::yellow,
155  unsigned int thickness=1) ;
156 
158  static double getLambda(){return gain;}
159  int readData(const char *filename) ;
160  static int readGrid(const char *filename,unsigned int &n,
161  std::list<double> &oX, std::list<double> &oY, std::list<double> &oZ,
162  bool verbose = false);
163 
165  static void setLambda(const double &lambda){gain = lambda;}
166  int writeData(const char *filename) ;
167 
168 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
169 
172  static void calibrationTsai(unsigned int nbPose, vpHomogeneousMatrix cMo[],
173  vpHomogeneousMatrix rMe[],
174  vpHomogeneousMatrix &eMc);
175  static int computeCalibrationMulti(vpCalibrationMethodType method,unsigned int nbPose,
176  vpCalibration table_cal[],
177  vpCameraParameters &cam,
178  bool verbose = false) ;
179  vp_deprecated static int computeCalibrationTsai(unsigned int nbPose,
180  vpCalibration table_cal[],
181  vpHomogeneousMatrix &eMc,
182  vpHomogeneousMatrix &eMc_dist);
183  vp_deprecated static int readGrid(const char *filename,unsigned int &n,
185  bool verbose = false);
186 #endif
187 
188 private:
189  void computePose(const vpCameraParameters &cam, vpHomogeneousMatrix &cMo);
190  void calibLagrange( vpCameraParameters &cam , vpHomogeneousMatrix &cMo) ;
191 
193  void calibVVS( vpCameraParameters &cam , vpHomogeneousMatrix &cMo,
194  bool verbose = false) ;
195 
196  static void calibVVSMulti(unsigned int nbPose, vpCalibration table_cal[],
197  vpCameraParameters &cam, bool verbose = false);
198  static void calibVVSMulti(std::vector<vpCalibration> &table_cal,
199  vpCameraParameters &cam,
200  double &globalReprojectionError, bool verbose = false) ;
201  void calibVVSWithDistortion( vpCameraParameters &cam,
202  vpHomogeneousMatrix &cMo,
203  bool verbose = false) ;
204  static void calibVVSWithDistortionMulti( unsigned int nbPose,
205  vpCalibration table_cal[],
206  vpCameraParameters &cam,
207  bool verbose = false );
208  static void calibVVSWithDistortionMulti( std::vector<vpCalibration> &table_cal,
209  vpCameraParameters &cam,
210  double &globalReprojectionError,
211  bool verbose = false);
212 
213 private:
214  unsigned int npt ;
215  std::list<double> LoX, LoY, LoZ ;
216  std::list<vpImagePoint> Lip ;
217 
218  double residual ;
219  double residual_dist ;
220 
221  static double threshold;
222  static unsigned int nbIterMax;
223  static double gain;
224 
225 } ;
226 
227 #endif
228 
229 /*
230  * Local variables:
231  * c-basic-offset: 2
232  * End:
233  */
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:112
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