Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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
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 
91 inline static void
93  const double &u, const double &v,
94  double &x, double &y)
95 {
96  switch(cam.projModel){
98  convertPointWithoutDistortion(cam,u,v,x,y);
99  break;
101  convertPointWithDistortion(cam,u,v,x,y);
102  break;
103  }
104 }
105 
129 inline static void
131  const vpImagePoint &iP,
132  double &x, double &y)
133 {
134  switch(cam.projModel){
136  convertPointWithoutDistortion(cam,iP,x,y);
137  break;
139  convertPointWithDistortion(cam,iP,x,y);
140  break;
141  }
142 }
143 
156 inline static void
158  const vpCameraParameters &cam,
159  const double &u, const double &v,
160  double &x, double &y)
161 {
162  x = (u - cam.u0)*cam.inv_px ;
163  y = (v - cam.v0)*cam.inv_py ;
164 }
165 
179 inline static void
181  const vpCameraParameters &cam,
182  const vpImagePoint &iP,
183  double &x, double &y)
184 {
185  x = (iP.get_u() - cam.u0)*cam.inv_px ;
186  y = (iP.get_v() - cam.v0)*cam.inv_py ;
187 }
188 
203 inline static void
205  const vpCameraParameters &cam,
206  const double &u, const double &v,
207  double &x, double &y)
208 {
209  double r2 = 1.+cam.kdu*(vpMath::sqr((u - cam.u0)*cam.inv_px) +
210  vpMath::sqr((v-cam.v0)*cam.inv_py));
211  x = (u - cam.u0)*r2*cam.inv_px ;
212  y = (v - cam.v0)*r2*cam.inv_py ;
213 }
214 
230 inline static void
232  const vpCameraParameters &cam,
233  const vpImagePoint &iP,
234  double &x, double &y)
235 {
236  double r2 = 1.+cam.kdu*(vpMath::sqr((iP.get_u() - cam.u0)*cam.inv_px) +
237  vpMath::sqr((iP.get_v()-cam.v0)*cam.inv_py));
238  x = (iP.get_u() - cam.u0)*r2*cam.inv_px ;
239  y = (iP.get_v() - cam.v0)*r2*cam.inv_py ;
240 }
241 
243  static void convertLine(const vpCameraParameters &cam,
244  const double &rho_p, const double &theta_p,
245  double &rho_m, double &theta_m) ;
246 
247 
248  static void convertMoment(const vpCameraParameters &cam,
249  unsigned int order,
250  const vpMatrix &moment_pixel,
251  vpMatrix &moment_meter) ;
252 } ;
253 
254 #endif
255 /*
256  * Local variables:
257  * c-basic-offset: 2
258  * End:
259  */
260 
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:97
double get_v() const
Definition: vpImagePoint.h:268
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:257
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.