Visual Servoing Platform version 3.5.0
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
258class VISP_EXPORT vpCameraParameters
259{
262
263public:
264 typedef enum {
265 perspectiveProjWithoutDistortion,
267 perspectiveProjWithDistortion,
269 ProjWithKannalaBrandtDistortion
271 } vpCameraParametersProjType;
272
273 // generic functions
276 vpCameraParameters(double px, double py, double u0, double v0);
277 vpCameraParameters(double px, double py, double u0, double v0, double kud, double kdu);
278 vpCameraParameters(double px, double py, double u0, double v0, const std::vector<double> &distortion_coefficients);
279
280 vpCameraParameters &operator=(const vpCameraParameters &c);
281 bool operator==(const vpCameraParameters &c) const;
282 bool operator!=(const vpCameraParameters &c) const;
283 virtual ~vpCameraParameters();
284
285 void init();
286 void init(const vpCameraParameters &c);
287 void initFromCalibrationMatrix(const vpMatrix &_K);
288 void initFromFov(const unsigned int &w, const unsigned int &h, const double &hfov, const double &vfov);
289 void initPersProjWithoutDistortion(double px, double py, double u0, double v0);
290 void initPersProjWithDistortion(double px, double py, double u0, double v0, double kud, double kdu);
291 void initProjWithKannalaBrandtDistortion(double px, double py, double u0, double v0, const std::vector<double> &distortion_coefficients);
292
300 inline bool isFovComputed() const { return isFov; }
301
302 void computeFov(const unsigned int &w, const unsigned int &h);
303
311 inline double getHorizontalFovAngle() const
312 {
313 if (!isFov) {
314 vpTRACE("Warning: The FOV is not computed, getHorizontalFovAngle() "
315 "won't be significant.");
316 }
317 return m_hFovAngle;
318 }
319
327 inline double getVerticalFovAngle() const
328 {
329 if (!isFov) {
330 vpTRACE("Warning: The FOV is not computed, getVerticalFovAngle() won't "
331 "be significant.");
332 }
333 return m_vFovAngle;
334 }
335
348 inline std::vector<vpColVector> getFovNormals() const
349 {
350 if (!isFov) {
351 vpTRACE("Warning: The FOV is not computed, getFovNormals() won't be "
352 "significant.");
353 }
354 return fovNormals;
355 }
356
357 inline double get_px() const { return px; }
358 inline double get_px_inverse() const { return inv_px; }
359 inline double get_py_inverse() const { return inv_py; }
360 inline double get_py() const { return py; }
361 inline double get_u0() const { return u0; }
362 inline double get_v0() const { return v0; }
363 inline double get_kud() const { return kud; }
364 inline double get_kdu() const { return kdu; }
365 inline std::vector<double> getKannalaBrandtDistortionCoefficients() const { return m_dist_coefs; }
366
367 inline vpCameraParametersProjType get_projModel() const { return projModel; }
368
369 vpMatrix get_K() const;
370 vpMatrix get_K_inverse() const;
371
372 void printParameters();
373 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCameraParameters &cam);
374
375private:
376 static const double DEFAULT_U0_PARAMETER;
377 static const double DEFAULT_V0_PARAMETER;
378 static const double DEFAULT_PX_PARAMETER;
379 static const double DEFAULT_PY_PARAMETER;
380 static const double DEFAULT_KUD_PARAMETER;
381 static const double DEFAULT_KDU_PARAMETER;
382 static const vpCameraParametersProjType DEFAULT_PROJ_TYPE;
383
384 double px, py;
385 double u0, v0;
386 double kud;
387 double kdu;
388 std::vector<double> m_dist_coefs;
389
390 unsigned int width;
391 unsigned int height;
392 bool isFov;
393 double m_hFovAngle;
394 double m_vFovAngle;
395 std::vector<vpColVector> fovNormals;
396
397 double inv_px, inv_py;
398
399 vpCameraParametersProjType projModel;
400};
401
402#endif
Generic class defining intrinsic camera parameters.
bool isFovComputed() const
double getHorizontalFovAngle() const
std::vector< double > getKannalaBrandtDistortionCoefficients() const
std::vector< vpColVector > getFovNormals() const
double getVerticalFovAngle() const
double get_px_inverse() const
double get_kdu() const
double get_py_inverse() const
vpCameraParametersProjType get_projModel() const
double get_kud() const
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:154
#define vpTRACE
Definition: vpDebug.h:416