ViSP  2.8.0
vpPixelMeterConversion.h
1 /****************************************************************************
2  *
3  * $Id: vpPixelMeterConversion.h 4056 2013-01-05 13:04:42Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Pixel to meter conversion.
36  *
37  * Authors:
38  * Eric Marchand
39  * Anthony Saunier
40  *
41  *****************************************************************************/
42 
43 #ifndef vpPixelMeterConversion_H
44 #define vpPixelMeterConversion_H
45 
46 
52 #include <visp/vpCameraParameters.h>
53 #include <visp/vpException.h>
54 #include <visp/vpMath.h>
55 #include <visp/vpDebug.h>
56 #include <visp/vpImagePoint.h>
57 
69 class VISP_EXPORT vpPixelMeterConversion
70 {
71 public:
72 
93 inline static void
95  const double &u, const double &v,
96  double &x, double &y)
97 {
98  switch(cam.projModel){
100  convertPointWithoutDistortion(cam,u,v,x,y);
101  break;
103  convertPointWithDistortion(cam,u,v,x,y);
104  break;
105  }
106 }
107 
130 inline static void
132  const vpImagePoint &iP,
133  double &x, double &y)
134 {
135  switch(cam.projModel){
137  convertPointWithoutDistortion(cam,iP,x,y);
138  break;
140  convertPointWithDistortion(cam,iP,x,y);
141  break;
142  }
143 }
144 
155 inline static void
157  const vpCameraParameters &cam,
158  const double &u, const double &v,
159  double &x, double &y)
160 {
161  x = (u - cam.u0)*cam.inv_px ;
162  y = (v - cam.v0)*cam.inv_py ;
163 }
164 
177 inline static void
179  const vpCameraParameters &cam,
180  const vpImagePoint &iP,
181  double &x, double &y)
182 {
183  x = (iP.get_u() - cam.u0)*cam.inv_px ;
184  y = (iP.get_v() - cam.v0)*cam.inv_py ;
185 }
186 
199 inline static void
201  const vpCameraParameters &cam,
202  const double &u, const double &v,
203  double &x, double &y)
204 {
205  double r2 = 1.+cam.kdu*(vpMath::sqr((u - cam.u0)*cam.inv_px) +
206  vpMath::sqr((v-cam.v0)*cam.inv_py));
207  x = (u - cam.u0)*r2*cam.inv_px ;
208  y = (v - cam.v0)*r2*cam.inv_py ;
209 }
210 
225 inline static void
227  const vpCameraParameters &cam,
228  const vpImagePoint &iP,
229  double &x, double &y)
230 {
231  double r2 = 1.+cam.kdu*(vpMath::sqr((iP.get_u() - cam.u0)*cam.inv_px) +
232  vpMath::sqr((iP.get_v()-cam.v0)*cam.inv_py));
233  x = (iP.get_u() - cam.u0)*r2*cam.inv_px ;
234  y = (iP.get_v() - cam.v0)*r2*cam.inv_py ;
235 }
236 
238  static void convertLine(const vpCameraParameters &cam,
239  const double &rho_p, const double &theta_p,
240  double &rho_m, double &theta_m) ;
241 
242 
243  static void convertMoment(const vpCameraParameters &cam,
244  unsigned int order,
245  const vpMatrix &moment_pixel,
246  vpMatrix &moment_meter) ;
247 } ;
248 
249 #endif
250 /*
251  * Local variables:
252  * c-basic-offset: 2
253  * End:
254  */
255 
Definition of the vpMatrix class.
Definition: vpMatrix.h:96
double get_v() const
Definition: vpImagePoint.h:250
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:239
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:106
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:92
Conversion from pixel coordinates to normalized coordinates in meter.