ViSP  2.10.0
vpMeterPixelConversion.h
1 /****************************************************************************
2  *
3  * $Id: vpMeterPixelConversion.h 4726 2014-04-23 11:58:11Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 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  * Meter to pixel conversion.
36  *
37  * Authors:
38  * Eric Marchand
39  * Anthony Saunier
40  *
41  *****************************************************************************/
42 
43 
44 #ifndef vpMeterPixelConversion_H
45 #define vpMeterPixelConversion_H
46 
47 
54 #include <visp/vpCameraParameters.h>
55 #include <visp/vpCircle.h>
56 #include <visp/vpException.h>
57 #include <visp/vpImagePoint.h>
58 #include <visp/vpMath.h>
59 
71 class VISP_EXPORT vpMeterPixelConversion
72 {
73 public:
74  static void convertEllipse(const vpCameraParameters &cam,
75  const vpCircle &circle, vpImagePoint &center,
76  double &mu20_p, double &mu11_p, double &mu02_p);
77 
78  static void convertLine(const vpCameraParameters &cam,
79  const double &rho_m, const double &theta_m,
80  double &rho_p, double &theta_p) ;
81 
103  inline static void
105  const double &x, const double &y,
106  double &u, double &v)
107  {
108  switch(cam.projModel){
110  convertPointWithoutDistortion(cam,x,y,u,v);
111  break;
113  convertPointWithDistortion(cam,x,y,u,v);
114  break;
115  }
116  }
117 
141  inline static void
143  const double &x, const double &y,
144  vpImagePoint &iP)
145  {
146  switch(cam.projModel){
148  convertPointWithoutDistortion(cam,x,y,iP);
149  break;
151  convertPointWithDistortion(cam,x,y,iP);
152  break;
153  }
154  }
155 
156 #ifndef DOXYGEN_SHOULD_SKIP_THIS
157 
166  inline static void
167  convertPointWithoutDistortion(const vpCameraParameters &cam,
168  const double &x, const double &y,
169  double &u, double &v)
170  {
171  u = x * cam.px + cam.u0 ;
172  v = y * cam.py + cam.v0 ;
173  }
174 
185  inline static void
186  convertPointWithoutDistortion(const vpCameraParameters &cam,
187  const double &x, const double &y,
188  vpImagePoint &iP)
189  {
190  iP.set_u( x * cam.px + cam.u0 );
191  iP.set_v( y * cam.py + cam.v0 );
192  }
193 
208  inline static void
209  convertPointWithDistortion(const vpCameraParameters &cam,
210  const double &x, const double &y,
211  double &u, double &v)
212  {
213  double r2 = 1.+cam.kud*(x*x+y*y);
214  u = cam.u0 + cam.px*x*r2;
215  v = cam.v0 + cam.py*y*r2;
216  }
217 
233  inline static void
234  convertPointWithDistortion(const vpCameraParameters &cam,
235  const double &x, const double &y,
236  vpImagePoint &iP)
237  {
238  double r2 = 1.+cam.kud*(x*x+y*y);
239  iP.set_u( cam.u0 + cam.px*x*r2 );
240  iP.set_v( cam.v0 + cam.py*y*r2 );
241  }
242 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
243 } ;
244 
245 #endif
246 
247 
Perspective projection without distortion model.
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:217
void set_v(const double v)
Definition: vpImagePoint.h:228
Generic class defining intrinsic camera parameters.
Perspective projection with distortion model.
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:93
Class that defines what is a circle.
Definition: vpCircle.h:61