Visual Servoing Platform  version 3.1.0
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 modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Camera intrinsic parameters.
33  *
34  * Authors:
35  * Eric Marchand
36  * Anthony Saunier
37  *
38  *****************************************************************************/
39 
47 #ifndef vpCameraParameters_H
48 #define vpCameraParameters_H
49 
50 #include <vector>
51 
52 #include <visp3/core/vpColVector.h>
53 #include <visp3/core/vpConfig.h>
54 #include <visp3/core/vpDebug.h>
55 #include <visp3/core/vpMatrix.h>
56 
232 class VISP_EXPORT vpCameraParameters
233 {
236 
237 public:
238  typedef enum {
239  perspectiveProjWithoutDistortion,
240  perspectiveProjWithDistortion
244 
245  // generic functions
248  vpCameraParameters(const double px, const double py, const double u0, const double v0);
249  vpCameraParameters(const double px, const double py, const double u0, const double v0, const double kud,
250  const double kdu);
251 
252  vpCameraParameters &operator=(const vpCameraParameters &c);
253  virtual ~vpCameraParameters();
254 
255  void init();
256  void init(const vpCameraParameters &c);
257  void initFromCalibrationMatrix(const vpMatrix &_K);
258  void initFromFov(const unsigned int &w, const unsigned int &h, const double &hfov, const double &vfov);
259  void initPersProjWithoutDistortion(const double px, const double py, const double u0, const double v0);
260  void initPersProjWithDistortion(const double px, const double py, const double u0, const double v0, const double kud,
261  const double kdu);
262 
270  inline bool isFovComputed() const { return isFov; }
271 
272  void computeFov(const unsigned int &w, const unsigned int &h);
273 
281  inline double getHorizontalFovAngle() const
282  {
283  if (!isFov)
284  vpTRACE("Warning: The FOV is not computed, getHorizontalFovAngle() "
285  "won't be significant.");
286  return m_hFovAngle;
287  }
288 
296  inline double getVerticalFovAngle() const
297  {
298  if (!isFov)
299  vpTRACE("Warning: The FOV is not computed, getVerticalFovAngle() won't "
300  "be significant.");
301  return m_vFovAngle;
302  }
303 
316  inline std::vector<vpColVector> getFovNormals() const
317  {
318  if (!isFov)
319  vpTRACE("Warning: The FOV is not computed, getFovNormals() won't be "
320  "significant.");
321  return fovNormals;
322  }
323 
324  inline double get_px() const { return px; }
325  inline double get_px_inverse() const { return inv_px; }
326  inline double get_py_inverse() const { return inv_py; }
327  inline double get_py() const { return py; }
328  inline double get_u0() const { return u0; }
329  inline double get_v0() const { return v0; }
330  inline double get_kud() const { return kud; }
331  inline double get_kdu() const { return kdu; }
332 
333  inline vpCameraParametersProjType get_projModel() const { return projModel; }
334 
335  vpMatrix get_K() const;
336  vpMatrix get_K_inverse() const;
337 
338  void printParameters();
339  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCameraParameters &cam);
340 
341 private:
342  static const double DEFAULT_U0_PARAMETER;
343  static const double DEFAULT_V0_PARAMETER;
344  static const double DEFAULT_PX_PARAMETER;
345  static const double DEFAULT_PY_PARAMETER;
346  static const double DEFAULT_KUD_PARAMETER;
347  static const double DEFAULT_KDU_PARAMETER;
348  static const vpCameraParametersProjType DEFAULT_PROJ_TYPE;
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
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
double get_kdu() const
vpCameraParametersProjType get_projModel() const
double getHorizontalFovAngle() const
bool isFovComputed() const
double get_py_inverse() const
#define vpTRACE
Definition: vpDebug.h:416
Generic class defining intrinsic camera parameters.
std::vector< vpColVector > getFovNormals() const
Conversion from normalized coordinates in meter to pixel coordinates .
double get_kud() const
double get_px_inverse() const
double getVerticalFovAngle() const
Conversion from pixel coordinates to normalized coordinates in meter.