Visual Servoing Platform  version 3.1.0
vpPixelMeterConversion.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  * Pixel to meter conversion.
33  *
34  * Authors:
35  * Eric Marchand
36  * Anthony Saunier
37  *
38  *****************************************************************************/
39 
40 #ifndef vpPixelMeterConversion_H
41 #define vpPixelMeterConversion_H
42 
48 #include <visp3/core/vpCameraParameters.h>
49 #include <visp3/core/vpDebug.h>
50 #include <visp3/core/vpException.h>
51 #include <visp3/core/vpImagePoint.h>
52 #include <visp3/core/vpMath.h>
53 
65 class VISP_EXPORT vpPixelMeterConversion
66 {
67 public:
90  inline static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
91  {
92  switch (cam.projModel) {
94  convertPointWithoutDistortion(cam, u, v, x, y);
95  break;
97  convertPointWithDistortion(cam, u, v, x, y);
98  break;
99  }
100  }
101 
126  inline static void convertPoint(const vpCameraParameters &cam, const vpImagePoint &iP, double &x, double &y)
127  {
128  switch (cam.projModel) {
130  convertPointWithoutDistortion(cam, iP, x, y);
131  break;
133  convertPointWithDistortion(cam, iP, x, y);
134  break;
135  }
136  }
137 
150  inline static void convertPointWithoutDistortion(const vpCameraParameters &cam, const double &u, const double &v,
151  double &x, double &y)
152  {
153  x = (u - cam.u0) * cam.inv_px;
154  y = (v - cam.v0) * cam.inv_py;
155  }
156 
172  inline static void convertPointWithoutDistortion(const vpCameraParameters &cam, const vpImagePoint &iP, double &x,
173  double &y)
174  {
175  x = (iP.get_u() - cam.u0) * cam.inv_px;
176  y = (iP.get_v() - cam.v0) * cam.inv_py;
177  }
178 
193  inline static void convertPointWithDistortion(const vpCameraParameters &cam, const double &u, const double &v,
194  double &x, double &y)
195  {
196  double r2 = 1. + cam.kdu * (vpMath::sqr((u - cam.u0) * cam.inv_px) + vpMath::sqr((v - cam.v0) * cam.inv_py));
197  x = (u - cam.u0) * r2 * cam.inv_px;
198  y = (v - cam.v0) * r2 * cam.inv_py;
199  }
200 
217  inline static void convertPointWithDistortion(const vpCameraParameters &cam, const vpImagePoint &iP, double &x,
218  double &y)
219  {
220  double r2 = 1. + cam.kdu * (vpMath::sqr((iP.get_u() - cam.u0) * cam.inv_px) +
221  vpMath::sqr((iP.get_v() - cam.v0) * cam.inv_py));
222  x = (iP.get_u() - cam.u0) * r2 * cam.inv_px;
223  y = (iP.get_v() - cam.v0) * r2 * cam.inv_py;
224  }
225 
227  static void convertLine(const vpCameraParameters &cam, const double &rho_p, const double &theta_p, double &rho_m,
228  double &theta_m);
229 
230  static void convertMoment(const vpCameraParameters &cam, unsigned int order, const vpMatrix &moment_pixel,
231  vpMatrix &moment_meter);
232 };
233 
234 #endif
235 /*
236  * Local variables:
237  * c-basic-offset: 2
238  * End:
239  */
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
static void convertPointWithDistortion(const vpCameraParameters &cam, const vpImagePoint &iP, double &x, double &y)
Point coordinates conversion with distortion from pixel coordinates Coordinates in pixel to normalize...
static void convertPointWithoutDistortion(const vpCameraParameters &cam, const vpImagePoint &iP, double &x, double &y)
Point coordinates conversion without distortion from pixel coordinates Coordinates in pixel to normal...
static void convertPointWithDistortion(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Point coordinates conversion with distortion from pixel coordinates to normalized coordinates in me...
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Point coordinates conversion from pixel coordinates to normalized coordinates in meter...
static void convertPointWithoutDistortion(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Point coordinates conversion without distortion from pixel coordinates to normalized coordinates in...
double get_u() const
Definition: vpImagePoint.h:263
static double sqr(double x)
Definition: vpMath.h:108
Generic class defining intrinsic camera parameters.
static void convertPoint(const vpCameraParameters &cam, const vpImagePoint &iP, double &x, double &y)
Point coordinates conversion from pixel coordinates Coordinates in pixel to normalized coordinates i...
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
double get_v() const
Definition: vpImagePoint.h:274
Conversion from pixel coordinates to normalized coordinates in meter.