Visual Servoing Platform  version 3.0.0
vpMeterPixelConversion.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  * Meter to pixel conversion.
32  *
33  * Authors:
34  * Eric Marchand
35  * Anthony Saunier
36  *
37  *****************************************************************************/
38 
39 
40 #ifndef vpMeterPixelConversion_H
41 #define vpMeterPixelConversion_H
42 
43 
50 #include <visp3/core/vpCameraParameters.h>
51 #include <visp3/core/vpCircle.h>
52 #include <visp3/core/vpException.h>
53 #include <visp3/core/vpImagePoint.h>
54 #include <visp3/core/vpMath.h>
55 
67 class VISP_EXPORT vpMeterPixelConversion
68 {
69 public:
70  static void convertEllipse(const vpCameraParameters &cam,
71  const vpCircle &circle, vpImagePoint &center,
72  double &mu20_p, double &mu11_p, double &mu02_p);
73 
74  static void convertLine(const vpCameraParameters &cam,
75  const double &rho_m, const double &theta_m,
76  double &rho_p, double &theta_p) ;
77 
99  inline static void
101  const double &x, const double &y,
102  double &u, double &v)
103  {
104  switch(cam.projModel){
106  convertPointWithoutDistortion(cam,x,y,u,v);
107  break;
109  convertPointWithDistortion(cam,x,y,u,v);
110  break;
111  }
112  }
113 
137  inline static void
139  const double &x, const double &y,
140  vpImagePoint &iP)
141  {
142  switch(cam.projModel){
144  convertPointWithoutDistortion(cam,x,y,iP);
145  break;
147  convertPointWithDistortion(cam,x,y,iP);
148  break;
149  }
150  }
151 
152 #ifndef DOXYGEN_SHOULD_SKIP_THIS
153 
162  inline static void
163  convertPointWithoutDistortion(const vpCameraParameters &cam,
164  const double &x, const double &y,
165  double &u, double &v)
166  {
167  u = x * cam.px + cam.u0 ;
168  v = y * cam.py + cam.v0 ;
169  }
170 
181  inline static void
182  convertPointWithoutDistortion(const vpCameraParameters &cam,
183  const double &x, const double &y,
184  vpImagePoint &iP)
185  {
186  iP.set_u( x * cam.px + cam.u0 );
187  iP.set_v( y * cam.py + cam.v0 );
188  }
189 
204  inline static void
205  convertPointWithDistortion(const vpCameraParameters &cam,
206  const double &x, const double &y,
207  double &u, double &v)
208  {
209  double r2 = 1.+cam.kud*(x*x+y*y);
210  u = cam.u0 + cam.px*x*r2;
211  v = cam.v0 + cam.py*y*r2;
212  }
213 
229  inline static void
230  convertPointWithDistortion(const vpCameraParameters &cam,
231  const double &x, const double &y,
232  vpImagePoint &iP)
233  {
234  double r2 = 1.+cam.kud*(x*x+y*y);
235  iP.set_u( cam.u0 + cam.px*x*r2 );
236  iP.set_v( cam.v0 + cam.py*y*r2 );
237  }
238 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
239 } ;
240 
241 #endif
242 
243 
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:212
void set_v(const double v)
Definition: vpImagePoint.h:223
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:88
Class that defines what is a circle.
Definition: vpCircle.h:57