Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
vpCameraParameters.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 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 
233 class VISP_EXPORT vpCameraParameters
234 {
237 
238 public:
239  typedef enum {
240  perspectiveProjWithoutDistortion,
241  perspectiveProjWithDistortion
245 
246  // generic functions
249  vpCameraParameters(double px, double py, double u0, double v0);
250  vpCameraParameters(double px, double py, double u0, double v0, double kud, double kdu);
251 
252  vpCameraParameters &operator=(const vpCameraParameters &c);
253  bool operator==(const vpCameraParameters &c) const;
254  bool operator!=(const vpCameraParameters &c) const;
255  virtual ~vpCameraParameters();
256 
257  void init();
258  void init(const vpCameraParameters &c);
259  void initFromCalibrationMatrix(const vpMatrix &_K);
260  void initFromFov(const unsigned int &w, const unsigned int &h, const double &hfov, const double &vfov);
261  void initPersProjWithoutDistortion(double px, double py, double u0, double v0);
262  void initPersProjWithDistortion(double px, double py, double u0, double v0, double kud, double kdu);
263 
271  inline bool isFovComputed() const { return isFov; }
272 
273  void computeFov(const unsigned int &w, const unsigned int &h);
274 
282  inline double getHorizontalFovAngle() const
283  {
284  if (!isFov) {
285  vpTRACE("Warning: The FOV is not computed, getHorizontalFovAngle() "
286  "won't be significant.");
287  }
288  return m_hFovAngle;
289  }
290 
298  inline double getVerticalFovAngle() const
299  {
300  if (!isFov) {
301  vpTRACE("Warning: The FOV is not computed, getVerticalFovAngle() won't "
302  "be significant.");
303  }
304  return m_vFovAngle;
305  }
306 
319  inline std::vector<vpColVector> getFovNormals() const
320  {
321  if (!isFov) {
322  vpTRACE("Warning: The FOV is not computed, getFovNormals() won't be "
323  "significant.");
324  }
325  return fovNormals;
326  }
327 
328  inline double get_px() const { return px; }
329  inline double get_px_inverse() const { return inv_px; }
330  inline double get_py_inverse() const { return inv_py; }
331  inline double get_py() const { return py; }
332  inline double get_u0() const { return u0; }
333  inline double get_v0() const { return v0; }
334  inline double get_kud() const { return kud; }
335  inline double get_kdu() const { return kdu; }
336 
337  inline vpCameraParametersProjType get_projModel() const { return projModel; }
338 
339  vpMatrix get_K() const;
340  vpMatrix get_K_inverse() const;
341 
342  void printParameters();
343  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCameraParameters &cam);
344 
345 private:
346  static const double DEFAULT_U0_PARAMETER;
347  static const double DEFAULT_V0_PARAMETER;
348  static const double DEFAULT_PX_PARAMETER;
349  static const double DEFAULT_PY_PARAMETER;
350  static const double DEFAULT_KUD_PARAMETER;
351  static const double DEFAULT_KDU_PARAMETER;
352  static const vpCameraParametersProjType DEFAULT_PROJ_TYPE;
353 
354  double px, py;
355  double u0, v0;
356  double kud;
357  double kdu;
358 
359  unsigned int width;
360  unsigned int height;
361  bool isFov;
362  double m_hFovAngle;
363  double m_vFovAngle;
364  std::vector<vpColVector> fovNormals;
365 
366  double inv_px, inv_py;
367 
368  vpCameraParametersProjType projModel;
369 };
370 
371 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:164
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
double get_kud() const
double get_px_inverse() const
double getVerticalFovAngle() const