ViSP  2.9.0
vpCameraParameters.h
1 /****************************************************************************
2  *
3  * $Id: vpCameraParameters.h 4620 2014-01-27 21:28:32Z 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 intrinsic parameters.
36  *
37  * Authors:
38  * Eric Marchand
39  * Anthony Saunier
40  *
41  *****************************************************************************/
42 
43 
44 
52 #ifndef vpCameraParameters_H
53 #define vpCameraParameters_H
54 
55 #include <vector>
56 
57 #include <visp/vpConfig.h>
58 #include <visp/vpMatrix.h>
59 #include <visp/vpColVector.h>
60 #include <visp/vpDebug.h>
61 
202 class VISP_EXPORT vpCameraParameters
203 {
206 public :
207  typedef enum{
209  perspectiveProjWithDistortion
210  } vpCameraParametersProjType ;
211 
212 
213  //generic functions
216  vpCameraParameters(const double px, const double py,
217  const double u0, const double v0) ;
218  vpCameraParameters(const double px, const double py,
219  const double u0, const double v0,
220  const double kud, const double kdu) ;
221 
222  vpCameraParameters& operator =(const vpCameraParameters &c) ;
223  virtual ~vpCameraParameters() ;
224 
225  void init() ;
226  void init(const vpCameraParameters &c) ;
227  void initFromCalibrationMatrix(const vpMatrix& _K);
228 
229  void initPersProjWithoutDistortion(const double px, const double py,
230  const double u0, const double v0) ;
231  void initPersProjWithDistortion(const double px, const double py,
232  const double u0, const double v0, const double kud,const double kdu) ;
233 
241  inline bool isFovComputed() const { return isFov; }
242 
243  void computeFov(const unsigned int &w, const unsigned int &h);
244 
252  inline double getFovAngleX() const {
253  if(!isFov) vpTRACE("Warning: The FOV is not computed, getFovAngleX() won't be significant.");
254  return fovAngleX;
255  }
256 
264  inline double getFovAngleY() const {
265  if(!isFov) vpTRACE("Warning: The FOV is not computed, getFovAngleY() won't be significant.");
266  return fovAngleY;
267  }
268 
280  inline std::vector<vpColVector> getFovNormals() const {
281  if(!isFov) vpTRACE("Warning: The FOV is not computed, getFovNormals() won't be significant.");
282  return fovNormals;
283  }
284 
285  inline double get_px() const { return px; }
286  inline double get_px_inverse() const {return inv_px; }
287  inline double get_py_inverse() const {return inv_py; }
288  inline double get_py() const { return py; }
289  inline double get_u0() const { return u0; }
290  inline double get_v0() const { return v0; }
291  inline double get_kud() const { return kud; }
292  inline double get_kdu() const { return kdu; }
293 
295  return projModel;
296  }
297 
298  vpMatrix get_K() const;
299  vpMatrix get_K_inverse() const;
300 
301  void printParameters() ;
302  friend VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpCameraParameters &cam);
303 
304 private:
305  static const double DEFAULT_U0_PARAMETER;
306  static const double DEFAULT_V0_PARAMETER;
307  static const double DEFAULT_PX_PARAMETER;
308  static const double DEFAULT_PY_PARAMETER;
309  static const double DEFAULT_KUD_PARAMETER;
310  static const double DEFAULT_KDU_PARAMETER;
311  static const vpCameraParametersProjType DEFAULT_PROJ_TYPE;
312 
313 
314  double px, py ;
315  double u0, v0 ;
316  double kud ;
317  double kdu ;
318 
319  unsigned int width ;
320  unsigned int height ;
321  bool isFov ;
322  double fovAngleX ;
323  double fovAngleY ;
324  std::vector<vpColVector> fovNormals ;
325 
326  double inv_px, inv_py;
327 
328  vpCameraParametersProjType projModel ;
329 } ;
330 
331 #endif
Definition of the vpMatrix class.
Definition: vpMatrix.h:98
double get_u0() const
Perspective projection without distortion model.
double get_px_inverse() const
#define vpTRACE
Definition: vpDebug.h:418
bool isFovComputed() const
double get_py_inverse() const
double get_py() const
double get_v0() const
Generic class defining intrinsic camera parameters.
double get_px() const
double get_kud() const
Conversion from normalized coordinates in meter to pixel coordinates .
double getFovAngleY() const
vpCameraParametersProjType get_projModel() const
double get_kdu() const
double getFovAngleX() const
std::vector< vpColVector > getFovNormals() const
Conversion from pixel coordinates to normalized coordinates in meter.