Visual Servoing Platform  version 3.2.1 under development (2019-09-22) under development (2019-09-22)
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(const double px, const double py, const double u0, const double v0);
250  vpCameraParameters(const double px, const double py, const double u0, const double v0, const double kud,
251  const double kdu);
252 
253  vpCameraParameters &operator=(const vpCameraParameters &c);
254  bool operator==(const vpCameraParameters &c) const;
255  bool operator!=(const vpCameraParameters &c) const;
256  virtual ~vpCameraParameters();
257 
258  void init();
259  void init(const vpCameraParameters &c);
260  void initFromCalibrationMatrix(const vpMatrix &_K);
261  void initFromFov(const unsigned int &w, const unsigned int &h, const double &hfov, const double &vfov);
262  void initPersProjWithoutDistortion(const double px, const double py, const double u0, const double v0);
263  void initPersProjWithDistortion(const double px, const double py, const double u0, const double v0, const double kud,
264  const double kdu);
265 
273  inline bool isFovComputed() const { return isFov; }
274 
275  void computeFov(const unsigned int &w, const unsigned int &h);
276 
284  inline double getHorizontalFovAngle() const
285  {
286  if (!isFov) {
287  vpTRACE("Warning: The FOV is not computed, getHorizontalFovAngle() "
288  "won't be significant.");
289  }
290  return m_hFovAngle;
291  }
292 
300  inline double getVerticalFovAngle() const
301  {
302  if (!isFov) {
303  vpTRACE("Warning: The FOV is not computed, getVerticalFovAngle() won't "
304  "be significant.");
305  }
306  return m_vFovAngle;
307  }
308 
321  inline std::vector<vpColVector> getFovNormals() const
322  {
323  if (!isFov) {
324  vpTRACE("Warning: The FOV is not computed, getFovNormals() won't be "
325  "significant.");
326  }
327  return fovNormals;
328  }
329 
330  inline double get_px() const { return px; }
331  inline double get_px_inverse() const { return inv_px; }
332  inline double get_py_inverse() const { return inv_py; }
333  inline double get_py() const { return py; }
334  inline double get_u0() const { return u0; }
335  inline double get_v0() const { return v0; }
336  inline double get_kud() const { return kud; }
337  inline double get_kdu() const { return kdu; }
338 
339  inline vpCameraParametersProjType get_projModel() const { return projModel; }
340 
341  vpMatrix get_K() const;
342  vpMatrix get_K_inverse() const;
343 
344  void printParameters();
345  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCameraParameters &cam);
346 
347 private:
348  static const double DEFAULT_U0_PARAMETER;
349  static const double DEFAULT_V0_PARAMETER;
350  static const double DEFAULT_PX_PARAMETER;
351  static const double DEFAULT_PY_PARAMETER;
352  static const double DEFAULT_KUD_PARAMETER;
353  static const double DEFAULT_KDU_PARAMETER;
354  static const vpCameraParametersProjType DEFAULT_PROJ_TYPE;
355 
356  double px, py;
357  double u0, v0;
358  double kud;
359  double kdu;
360 
361  unsigned int width;
362  unsigned int height;
363  bool isFov;
364  double m_hFovAngle;
365  double m_vFovAngle;
366  std::vector<vpColVector> fovNormals;
367 
368  double inv_px, inv_py;
369 
370  vpCameraParametersProjType projModel;
371 };
372 
373 #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