ViSP  2.7.0
vpCalibration.h
1 /****************************************************************************
2  *
3  * $Id: vpCalibration.h 4056 2013-01-05 13:04:42Z 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(unsigned int nbPose, vpHomogeneousMatrix cMo[],
131  vpHomogeneousMatrix rMe[],
132  vpHomogeneousMatrix &eMc);
133  static void calibrationTsai(std::vector<vpHomogeneousMatrix> &cMo,
134  std::vector<vpHomogeneousMatrix> & rMe,
135  vpHomogeneousMatrix &eMc);
136 
137  void computeStdDeviation(double &deviation, double &deviation_dist);
138  int computeCalibration(vpCalibrationMethodType method,
139  vpHomogeneousMatrix &cMo,
140  vpCameraParameters &cam,
141  bool verbose = false) ;
142  static int computeCalibrationMulti(vpCalibrationMethodType method,unsigned int nbPose,
143  vpCalibration table_cal[],
144  vpCameraParameters &cam,
145  bool verbose = false) ;
146 
147  static int computeCalibrationTsai(unsigned int nbPose,
148  vpCalibration table_cal[],
149  vpHomogeneousMatrix &eMc,
150  vpHomogeneousMatrix &eMc_dist);
151  double computeStdDeviation(vpHomogeneousMatrix &cMo,
152  vpCameraParameters &cam);
153  double computeStdDeviation_dist(vpHomogeneousMatrix &cMo,
154  vpCameraParameters &cam);
155  int displayData(vpImage<unsigned char> &I, vpColor color=vpColor::red,
156  unsigned int thickness=1) ;
157  int displayGrid(vpImage<unsigned char> &I, vpColor color=vpColor::yellow,
158  unsigned int thickness=1) ;
159 
161  static double getLambda(){return gain;}
162  int readData(const char *filename) ;
163  static int readGrid(const char *filename,unsigned int &n,
164  std::list<double> &oX, std::list<double> &oY, std::list<double> &oZ,
165  bool verbose = false);
166 
168  static void setLambda(const double &lambda){gain = lambda;}
169  int writeData(const char *filename) ;
170 
171 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
172 
175  vp_deprecated static int readGrid(const char *filename,unsigned int &n,
177  bool verbose = false);
178 #endif
179 
180 private:
181  void computePose(const vpCameraParameters &cam, vpHomogeneousMatrix &cMo);
182  void calibLagrange( vpCameraParameters &cam , vpHomogeneousMatrix &cMo) ;
183 
185  void calibVVS( vpCameraParameters &cam , vpHomogeneousMatrix &cMo,
186  bool verbose = false) ;
187  static void calibVVSMulti(unsigned int nbPose, vpCalibration table_cal[] ,
188  vpCameraParameters &cam, bool verbose = false) ;
189  void calibVVSWithDistortion( vpCameraParameters &cam,
190  vpHomogeneousMatrix &cMo,
191  bool verbose = false) ;
192  static void calibVVSWithDistortionMulti( unsigned int nbPose,
193  vpCalibration table_cal[],
194  vpCameraParameters &cam,
195  bool verbose = false );
196 
197 private:
198  unsigned int npt ;
199  std::list<double> LoX, LoY, LoZ ;
200  std::list<vpImagePoint> Lip ;
201 
202  double residual ;
203  double residual_dist ;
204 
205  static double threshold;
206  static unsigned int nbIterMax;
207  static double gain;
208 
209 } ;
210 
211 #endif
212 
213 /*
214  * Local variables:
215  * c-basic-offset: 2
216  * End:
217  */
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:123
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:165
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:173
double getResidual(void) const
get the residual in pixels