Visual Servoing Platform  version 3.0.0
vpPixelMeterConversion.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Pixel to meter conversion.
32  *
33  * Authors:
34  * Eric Marchand
35  * Anthony Saunier
36  *
37  *****************************************************************************/
38 
39 #ifndef vpPixelMeterConversion_H
40 #define vpPixelMeterConversion_H
41 
42 
48 #include <visp3/core/vpCameraParameters.h>
49 #include <visp3/core/vpException.h>
50 #include <visp3/core/vpMath.h>
51 #include <visp3/core/vpDebug.h>
52 #include <visp3/core/vpImagePoint.h>
53 
65 class VISP_EXPORT vpPixelMeterConversion
66 {
67 public:
68 
89 inline static void
91  const double &u, const double &v,
92  double &x, double &y)
93 {
94  switch(cam.projModel){
96  convertPointWithoutDistortion(cam,u,v,x,y);
97  break;
99  convertPointWithDistortion(cam,u,v,x,y);
100  break;
101  }
102 }
103 
126 inline static void
128  const vpImagePoint &iP,
129  double &x, double &y)
130 {
131  switch(cam.projModel){
133  convertPointWithoutDistortion(cam,iP,x,y);
134  break;
136  convertPointWithDistortion(cam,iP,x,y);
137  break;
138  }
139 }
140 
151 inline static void
153  const vpCameraParameters &cam,
154  const double &u, const double &v,
155  double &x, double &y)
156 {
157  x = (u - cam.u0)*cam.inv_px ;
158  y = (v - cam.v0)*cam.inv_py ;
159 }
160 
173 inline static void
175  const vpCameraParameters &cam,
176  const vpImagePoint &iP,
177  double &x, double &y)
178 {
179  x = (iP.get_u() - cam.u0)*cam.inv_px ;
180  y = (iP.get_v() - cam.v0)*cam.inv_py ;
181 }
182 
195 inline static void
197  const vpCameraParameters &cam,
198  const double &u, const double &v,
199  double &x, double &y)
200 {
201  double r2 = 1.+cam.kdu*(vpMath::sqr((u - cam.u0)*cam.inv_px) +
202  vpMath::sqr((v-cam.v0)*cam.inv_py));
203  x = (u - cam.u0)*r2*cam.inv_px ;
204  y = (v - cam.v0)*r2*cam.inv_py ;
205 }
206 
221 inline static void
223  const vpCameraParameters &cam,
224  const vpImagePoint &iP,
225  double &x, double &y)
226 {
227  double r2 = 1.+cam.kdu*(vpMath::sqr((iP.get_u() - cam.u0)*cam.inv_px) +
228  vpMath::sqr((iP.get_v()-cam.v0)*cam.inv_py));
229  x = (iP.get_u() - cam.u0)*r2*cam.inv_px ;
230  y = (iP.get_v() - cam.v0)*r2*cam.inv_py ;
231 }
232 
234  static void convertLine(const vpCameraParameters &cam,
235  const double &rho_p, const double &theta_p,
236  double &rho_m, double &theta_m) ;
237 
238 
239  static void convertMoment(const vpCameraParameters &cam,
240  unsigned int order,
241  const vpMatrix &moment_pixel,
242  vpMatrix &moment_meter) ;
243 } ;
244 
245 #endif
246 /*
247  * Local variables:
248  * c-basic-offset: 2
249  * End:
250  */
251 
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:92
double get_v() const
Definition: vpImagePoint.h:259
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...
Perspective projection without distortion model.
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...
double get_u() const
Definition: vpImagePoint.h:248
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...
static double sqr(double x)
Definition: vpMath.h:110
Generic class defining intrinsic camera parameters.
Perspective projection with distortion model.
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
Conversion from pixel coordinates to normalized coordinates in meter.