ViSP  2.10.0
vpCameraParameters.h
1 /****************************************************************************
2  *
3  * $Id: vpCameraParameters.h 5207 2015-01-26 09:05:28Z 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 
210 class VISP_EXPORT vpCameraParameters
211 {
214 public :
215  typedef enum{
217  perspectiveProjWithDistortion
218  } vpCameraParametersProjType ;
219 
220 
221  //generic functions
224  vpCameraParameters(const double px, const double py,
225  const double u0, const double v0) ;
226  vpCameraParameters(const double px, const double py,
227  const double u0, const double v0,
228  const double kud, const double kdu) ;
229 
230  vpCameraParameters& operator =(const vpCameraParameters &c) ;
231  virtual ~vpCameraParameters() ;
232 
233  void init() ;
234  void init(const vpCameraParameters &c) ;
235  void initFromCalibrationMatrix(const vpMatrix& _K);
236  void initFromFov(const unsigned int &w, const unsigned int &h, const double &hfov, const double &vfov);
237  void initPersProjWithoutDistortion(const double px, const double py, const double u0, const double v0);
238  void initPersProjWithDistortion(const double px, const double py, const double u0, const double v0,
239  const double kud,const double kdu) ;
240 
248  inline bool isFovComputed() const { return isFov; }
249 
250  void computeFov(const unsigned int &w, const unsigned int &h);
251 
259  inline double getHorizontalFovAngle() const {
260  if(!isFov) vpTRACE("Warning: The FOV is not computed, getHorizontalFovAngle() won't be significant.");
261  return m_hFovAngle;
262  }
263 
271  inline double getVerticalFovAngle() const {
272  if(!isFov) vpTRACE("Warning: The FOV is not computed, getVerticalFovAngle() won't be significant.");
273  return m_vFovAngle;
274  }
275 
287  inline std::vector<vpColVector> getFovNormals() const {
288  if(!isFov) vpTRACE("Warning: The FOV is not computed, getFovNormals() won't be significant.");
289  return fovNormals;
290  }
291 
292  inline double get_px() const { return px; }
293  inline double get_px_inverse() const {return inv_px; }
294  inline double get_py_inverse() const {return inv_py; }
295  inline double get_py() const { return py; }
296  inline double get_u0() const { return u0; }
297  inline double get_v0() const { return v0; }
298  inline double get_kud() const { return kud; }
299  inline double get_kdu() const { return kdu; }
300 
302  return projModel;
303  }
304 
305  vpMatrix get_K() const;
306  vpMatrix get_K_inverse() const;
307 
308  void printParameters() ;
309  friend VISP_EXPORT std::ostream & operator << (std::ostream & os, const vpCameraParameters &cam);
310 
311 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
312 
320  vp_deprecated inline double getFovAngleX() const {
321  if(!isFov) vpTRACE("Warning: The FOV is not computed, getFovAngleX() won't be significant.");
322  return m_hFovAngle;
323  }
324 
333  vp_deprecated inline double getFovAngleY() const {
334  if(!isFov) vpTRACE("Warning: The FOV is not computed, getFovAngleY() won't be significant.");
335  return m_hFovAngle;
336  }
337 
338 #endif
339 
340 private:
341  static const double DEFAULT_U0_PARAMETER;
342  static const double DEFAULT_V0_PARAMETER;
343  static const double DEFAULT_PX_PARAMETER;
344  static const double DEFAULT_PY_PARAMETER;
345  static const double DEFAULT_KUD_PARAMETER;
346  static const double DEFAULT_KDU_PARAMETER;
347  static const vpCameraParametersProjType DEFAULT_PROJ_TYPE;
348 
349 
350  double px, py ;
351  double u0, v0 ;
352  double kud ;
353  double kdu ;
354 
355  unsigned int width ;
356  unsigned int height ;
357  bool isFov ;
358  double m_hFovAngle ;
359  double m_vFovAngle ;
360  std::vector<vpColVector> fovNormals ;
361 
362  double inv_px, inv_py;
363 
364  vpCameraParametersProjType projModel ;
365 } ;
366 
367 #endif
vp_deprecated double getFovAngleX() const
Definition of the vpMatrix class.
Definition: vpMatrix.h:98
double getHorizontalFovAngle() const
double get_u0() const
Perspective projection without distortion model.
double get_px_inverse() const
vp_deprecated double getFovAngleY() 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 .
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.