Visual Servoing Platform  version 3.1.0
vpMeterPixelConversion.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  * Meter to pixel conversion.
33  *
34  * Authors:
35  * Eric Marchand
36  * Anthony Saunier
37  *
38  *****************************************************************************/
39 
40 #ifndef vpMeterPixelConversion_H
41 #define vpMeterPixelConversion_H
42 
49 #include <visp3/core/vpCameraParameters.h>
50 #include <visp3/core/vpCircle.h>
51 #include <visp3/core/vpException.h>
52 #include <visp3/core/vpImagePoint.h>
53 #include <visp3/core/vpMath.h>
54 
66 class VISP_EXPORT vpMeterPixelConversion
67 {
68 public:
69  static void convertEllipse(const vpCameraParameters &cam, const vpCircle &circle, vpImagePoint &center,
70  double &mu20_p, double &mu11_p, double &mu02_p);
71 
72  static void convertLine(const vpCameraParameters &cam, const double &rho_m, const double &theta_m, double &rho_p,
73  double &theta_p);
74 
98  inline static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
99  {
100  switch (cam.projModel) {
102  convertPointWithoutDistortion(cam, x, y, u, v);
103  break;
105  convertPointWithDistortion(cam, x, y, u, v);
106  break;
107  }
108  }
109 
134  inline static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, vpImagePoint &iP)
135  {
136  switch (cam.projModel) {
138  convertPointWithoutDistortion(cam, x, y, iP);
139  break;
141  convertPointWithDistortion(cam, x, y, iP);
142  break;
143  }
144  }
145 
146 #ifndef DOXYGEN_SHOULD_SKIP_THIS
147 
156  inline static void convertPointWithoutDistortion(const vpCameraParameters &cam, const double &x, const double &y,
157  double &u, double &v)
158  {
159  u = x * cam.px + cam.u0;
160  v = y * cam.py + cam.v0;
161  }
162 
173  inline static void convertPointWithoutDistortion(const vpCameraParameters &cam, const double &x, const double &y,
174  vpImagePoint &iP)
175  {
176  iP.set_u(x * cam.px + cam.u0);
177  iP.set_v(y * cam.py + cam.v0);
178  }
179 
196  inline static void convertPointWithDistortion(const vpCameraParameters &cam, const double &x, const double &y,
197  double &u, double &v)
198  {
199  double r2 = 1. + cam.kud * (x * x + y * y);
200  u = cam.u0 + cam.px * x * r2;
201  v = cam.v0 + cam.py * y * r2;
202  }
203 
220  inline static void convertPointWithDistortion(const vpCameraParameters &cam, const double &x, const double &y,
221  vpImagePoint &iP)
222  {
223  double r2 = 1. + cam.kud * (x * x + y * y);
224  iP.set_u(cam.u0 + cam.px * x * r2);
225  iP.set_v(cam.v0 + cam.py * y * r2);
226  }
227 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
228 };
229 
230 #endif
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, vpImagePoint &iP)
Point coordinates conversion from normalized coordinates in meter to pixel coordinates.
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
Point coordinates conversion from normalized coordinates in meter to pixel coordinates ...
void set_u(const double u)
Definition: vpImagePoint.h:226
void set_v(const double v)
Definition: vpImagePoint.h:237
Generic class defining intrinsic camera parameters.
Conversion from normalized coordinates in meter to pixel coordinates .
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
Class that defines what is a circle.
Definition: vpCircle.h:58