Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpCameraParameters.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 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 
221 class VISP_EXPORT vpCameraParameters
222 {
225 public :
226  typedef enum{
228  perspectiveProjWithDistortion
229  } vpCameraParametersProjType ;
230 
231 
232  //generic functions
235  vpCameraParameters(const double px, const double py,
236  const double u0, const double v0) ;
237  vpCameraParameters(const double px, const double py,
238  const double u0, const double v0,
239  const double kud, const double kdu) ;
240 
241  vpCameraParameters& operator =(const vpCameraParameters &c) ;
242  virtual ~vpCameraParameters() ;
243 
244  void init() ;
245  void init(const vpCameraParameters &c) ;
246  void initFromCalibrationMatrix(const vpMatrix& _K);
247  void initFromFov(const unsigned int &w, const unsigned int &h, const double &hfov, const double &vfov);
248  void initPersProjWithoutDistortion(const double px, const double py, const double u0, const double v0);
249  void initPersProjWithDistortion(const double px, const double py, const double u0, const double v0,
250  const double kud,const double kdu) ;
251 
259  inline bool isFovComputed() const { return isFov; }
260 
261  void computeFov(const unsigned int &w, const unsigned int &h);
262 
270  inline double getHorizontalFovAngle() const {
271  if(!isFov) vpTRACE("Warning: The FOV is not computed, getHorizontalFovAngle() won't be significant.");
272  return m_hFovAngle;
273  }
274 
282  inline double getVerticalFovAngle() const {
283  if(!isFov) vpTRACE("Warning: The FOV is not computed, getVerticalFovAngle() won't be significant.");
284  return m_vFovAngle;
285  }
286 
298  inline std::vector<vpColVector> getFovNormals() const {
299  if(!isFov) vpTRACE("Warning: The FOV is not computed, getFovNormals() won't be significant.");
300  return fovNormals;
301  }
302 
303  inline double get_px() const { return px; }
304  inline double get_px_inverse() const {return inv_px; }
305  inline double get_py_inverse() const {return inv_py; }
306  inline double get_py() const { return py; }
307  inline double get_u0() const { return u0; }
308  inline double get_v0() const { return v0; }
309  inline double get_kud() const { return kud; }
310  inline double get_kdu() const { return kdu; }
311 
313  return projModel;
314  }
315 
316  vpMatrix get_K() const;
317  vpMatrix get_K_inverse() const;
318 
319  void printParameters() ;
320  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCameraParameters &cam);
321 
322 private:
323  static const double DEFAULT_U0_PARAMETER;
324  static const double DEFAULT_V0_PARAMETER;
325  static const double DEFAULT_PX_PARAMETER;
326  static const double DEFAULT_PY_PARAMETER;
327  static const double DEFAULT_KUD_PARAMETER;
328  static const double DEFAULT_KDU_PARAMETER;
329  static const vpCameraParametersProjType DEFAULT_PROJ_TYPE;
330 
331 
332  double px, py ;
333  double u0, v0 ;
334  double kud ;
335  double kdu ;
336 
337  unsigned int width ;
338  unsigned int height ;
339  bool isFov ;
340  double m_hFovAngle ;
341  double m_vFovAngle ;
342  std::vector<vpColVector> fovNormals ;
343 
344  double inv_px, inv_py;
345 
346  vpCameraParametersProjType projModel ;
347 } ;
348 
349 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:97
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.