Visual Servoing Platform  version 3.0.0
vpCameraParameters.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 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 intrinsic parameters.
32  *
33  * Authors:
34  * Eric Marchand
35  * Anthony Saunier
36  *
37  *****************************************************************************/
38 
39 
40 
48 #ifndef vpCameraParameters_H
49 #define vpCameraParameters_H
50 
51 #include <vector>
52 
53 #include <visp3/core/vpConfig.h>
54 #include <visp3/core/vpMatrix.h>
55 #include <visp3/core/vpColVector.h>
56 #include <visp3/core/vpDebug.h>
57 
218 class VISP_EXPORT vpCameraParameters
219 {
222 public :
223  typedef enum{
225  perspectiveProjWithDistortion
226  } vpCameraParametersProjType ;
227 
228 
229  //generic functions
232  vpCameraParameters(const double px, const double py,
233  const double u0, const double v0) ;
234  vpCameraParameters(const double px, const double py,
235  const double u0, const double v0,
236  const double kud, const double kdu) ;
237 
238  vpCameraParameters& operator =(const vpCameraParameters &c) ;
239  virtual ~vpCameraParameters() ;
240 
241  void init() ;
242  void init(const vpCameraParameters &c) ;
243  void initFromCalibrationMatrix(const vpMatrix& _K);
244  void initFromFov(const unsigned int &w, const unsigned int &h, const double &hfov, const double &vfov);
245  void initPersProjWithoutDistortion(const double px, const double py, const double u0, const double v0);
246  void initPersProjWithDistortion(const double px, const double py, const double u0, const double v0,
247  const double kud,const double kdu) ;
248 
256  inline bool isFovComputed() const { return isFov; }
257 
258  void computeFov(const unsigned int &w, const unsigned int &h);
259 
267  inline double getHorizontalFovAngle() const {
268  if(!isFov) vpTRACE("Warning: The FOV is not computed, getHorizontalFovAngle() won't be significant.");
269  return m_hFovAngle;
270  }
271 
279  inline double getVerticalFovAngle() const {
280  if(!isFov) vpTRACE("Warning: The FOV is not computed, getVerticalFovAngle() won't be significant.");
281  return m_vFovAngle;
282  }
283 
295  inline std::vector<vpColVector> getFovNormals() const {
296  if(!isFov) vpTRACE("Warning: The FOV is not computed, getFovNormals() won't be significant.");
297  return fovNormals;
298  }
299 
300  inline double get_px() const { return px; }
301  inline double get_px_inverse() const {return inv_px; }
302  inline double get_py_inverse() const {return inv_py; }
303  inline double get_py() const { return py; }
304  inline double get_u0() const { return u0; }
305  inline double get_v0() const { return v0; }
306  inline double get_kud() const { return kud; }
307  inline double get_kdu() const { return kdu; }
308 
310  return projModel;
311  }
312 
313  vpMatrix get_K() const;
314  vpMatrix get_K_inverse() const;
315 
316  void printParameters() ;
317  friend VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpCameraParameters &cam);
318 
319 private:
320  static const double DEFAULT_U0_PARAMETER;
321  static const double DEFAULT_V0_PARAMETER;
322  static const double DEFAULT_PX_PARAMETER;
323  static const double DEFAULT_PY_PARAMETER;
324  static const double DEFAULT_KUD_PARAMETER;
325  static const double DEFAULT_KDU_PARAMETER;
326  static const vpCameraParametersProjType DEFAULT_PROJ_TYPE;
327 
328 
329  double px, py ;
330  double u0, v0 ;
331  double kud ;
332  double kdu ;
333 
334  unsigned int width ;
335  unsigned int height ;
336  bool isFov ;
337  double m_hFovAngle ;
338  double m_vFovAngle ;
339  std::vector<vpColVector> fovNormals ;
340 
341  double inv_px, inv_py;
342 
343  vpCameraParametersProjType projModel ;
344 } ;
345 
346 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:92
double getHorizontalFovAngle() const
double get_u0() const
Perspective projection without distortion model.
double get_px_inverse() const
bool isFovComputed() const
double get_py_inverse() const
double get_py() const
double get_v0() const
#define vpTRACE
Definition: vpDebug.h:414
Generic class defining intrinsic camera parameters.
double get_px() const
double get_kud() const
Conversion from normalized coordinates in meter to pixel coordinates .
vpCameraParametersProjType get_projModel() const
double get_kdu() const
std::vector< vpColVector > getFovNormals() const
double getVerticalFovAngle() const
Conversion from pixel coordinates to normalized coordinates in meter.