Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpMeterPixelConversion.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  * 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 
101  inline static void
103  const double &x, const double &y,
104  double &u, double &v)
105  {
106  switch(cam.projModel){
108  convertPointWithoutDistortion(cam,x,y,u,v);
109  break;
111  convertPointWithDistortion(cam,x,y,u,v);
112  break;
113  }
114  }
115 
140  inline static void
142  const double &x, const double &y,
143  vpImagePoint &iP)
144  {
145  switch(cam.projModel){
147  convertPointWithoutDistortion(cam,x,y,iP);
148  break;
150  convertPointWithDistortion(cam,x,y,iP);
151  break;
152  }
153  }
154 
155 #ifndef DOXYGEN_SHOULD_SKIP_THIS
156 
165  inline static void
166  convertPointWithoutDistortion(const vpCameraParameters &cam,
167  const double &x, const double &y,
168  double &u, double &v)
169  {
170  u = x * cam.px + cam.u0 ;
171  v = y * cam.py + cam.v0 ;
172  }
173 
184  inline static void
185  convertPointWithoutDistortion(const vpCameraParameters &cam,
186  const double &x, const double &y,
187  vpImagePoint &iP)
188  {
189  iP.set_u( x * cam.px + cam.u0 );
190  iP.set_v( y * cam.py + cam.v0 );
191  }
192 
209  inline static void
210  convertPointWithDistortion(const vpCameraParameters &cam,
211  const double &x, const double &y,
212  double &u, double &v)
213  {
214  double r2 = 1.+cam.kud*(x*x+y*y);
215  u = cam.u0 + cam.px*x*r2;
216  v = cam.v0 + cam.py*y*r2;
217  }
218 
235  inline static void
236  convertPointWithDistortion(const vpCameraParameters &cam,
237  const double &x, const double &y,
238  vpImagePoint &iP)
239  {
240  double r2 = 1.+cam.kud*(x*x+y*y);
241  iP.set_u( cam.u0 + cam.px*x*r2 );
242  iP.set_v( cam.v0 + cam.py*y*r2 );
243  }
244 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
245 } ;
246 
247 #endif
248 
249 
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:221
void set_v(const double v)
Definition: vpImagePoint.h:232
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