ViSP  2.6.2
vpPoint.h
1 /****************************************************************************
2  *
3  * $Id: vpPoint.h 3653 2012-03-28 12:43:23Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2012 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  * Point feature.
36  *
37  * Authors:
38  * Eric Marchand
39  *
40  *****************************************************************************/
41 
42 
43 #ifndef vpPoint_H
44 #define vpPoint_H
45 
46 class vpHomography ;
47 
53 #include <visp/vpMatrix.h>
54 #include <visp/vpHomogeneousMatrix.h>
55 
56 #include <visp/vpForwardProjection.h>
57 
58 class vpHomography;
59 
65 class VISP_EXPORT vpPoint : public vpForwardProjection
66 {
67 
68 public:
70  vpPoint() ;
72  virtual ~vpPoint() { ; }
73 
74 public:
75 
76  // Compute the 3D coordinates _cP (camera frame)
77  void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &_cP) ;
78 
87  inline void changeFrame(const vpHomogeneousMatrix &cMo) {
88  double X = cMo[0][0]*oP[0]+ cMo[0][1]*oP[1]+ cMo[0][2]*oP[2]+ cMo[0][3]*oP[3] ;
89  double Y = cMo[1][0]*oP[0]+ cMo[1][1]*oP[1]+ cMo[1][2]*oP[2]+ cMo[1][3]*oP[3] ;
90  double Z = cMo[2][0]*oP[0]+ cMo[2][1]*oP[1]+ cMo[2][2]*oP[2]+ cMo[2][3]*oP[3] ;
91  double W = cMo[3][0]*oP[0]+ cMo[3][1]*oP[1]+ cMo[3][2]*oP[2]+ cMo[3][3]*oP[3] ;
92 
93  double d = 1/W ;
94  cP[0] =X*d ;
95  cP[1] =Y*d ;
96  cP[2] =Z*d ;
97  cP[3] =1 ;
98  }
99 
100  void display(const vpImage<unsigned char> &I,
101  const vpCameraParameters &cam,
102  const vpColor &color=vpColor::green,
103  const unsigned int thickness=1) ;
104  void display(const vpImage<unsigned char> &I,
105  const vpHomogeneousMatrix &cMo,
106  const vpCameraParameters &cam,
107  const vpColor &color=vpColor::green,
108  const unsigned int thickness=1) ;
109  void display(const vpImage<vpRGBa> &I,
110  const vpHomogeneousMatrix &cMo,
111  const vpCameraParameters &cam,
112  const vpColor &color=vpColor::green,
113  const unsigned int thickness=1) ;
114  vpPoint *duplicate() const ;
115 
117  void init() ;
118 
119  /*
120  \section Get coordinates
121  */
122 
124  double get_X() const { return cP[0] ; }
127  double get_Y() const { return cP[1] ; }
129  double get_Z() const { return cP[2] ; }
131  double get_W() const { return cP[3] ; }
132 
134  double get_oX() const { return oP[0] ; }
136  double get_oY() const { return oP[1] ; }
138  double get_oZ() const { return oP[2] ; }
140  double get_oW() const { return oP[3] ; }
141 
143  double get_x() const { return p[0] ; }
145  double get_y() const { return p[1] ; }
147  double get_w() const { return p[2] ; }
148 
150  void getWorldCoordinates(double& ox,
151  double& oy,
152  double& oz) ;
154  void getWorldCoordinates(vpColVector &_oP) ;
155  vpColVector getWorldCoordinates(void) ;
157 
158  /*
159  \section Set coordinates
160  */
161 
163 
165  inline void set_X(const double X) { cP[0] = X ; }
167  inline void set_Y(const double Y) { cP[1] = Y ; }
169  inline void set_Z(const double Z) { cP[2] = Z ; }
171  inline void set_W(const double W) { cP[3] = W ; }
172 
174  inline void set_oX(const double X) { oP[0] = X ; }
176  inline void set_oY(const double Y) { oP[1] = Y ; }
178  inline void set_oZ(const double Z) { oP[2] = Z ; }
180  inline void set_oW(const double W) { oP[3] = W ; }
181 
183  inline void set_x(const double x) { p[0] = x ; }
185  inline void set_y(const double y) { p[1] = y ; }
187  inline void set_w(const double w) { p[2] = w ; }
188 
190  void setWorldCoordinates(const double ox,
191  const double oy,
192  const double oz) ;
194  void setWorldCoordinates(const vpColVector &_oP) ;
196 
198  void projection(const vpColVector &_cP, vpColVector &_p) ;
199 
208  inline void projection() {
209  double d = 1/cP[2] ;
210  p[0] = cP[0]*d ;
211  p[1] = cP[1]*d ;
212  p[2] = 1 ;
213  }
214 
215  friend VISP_EXPORT std::ostream& operator<<(std::ostream& os, vpPoint& vpp);
216  vpPoint& operator=(const vpPoint& vpp);
217 } ;
218 
219 
220 const vpPoint VISP_EXPORT operator*(const vpHomogeneousMatrix &M, const vpPoint& p) ;
221 const vpPoint VISP_EXPORT operator*(const vpHomography &H, const vpPoint& p) ;
222 
223 #endif
224 
225 /*
226  * Local variables:
227  * c-basic-offset: 2
228  * End:
229  */
vpTracker & operator=(const vpTracker &tracker)
Copy operator.
Definition: vpTracker.cpp:72
virtual void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP)=0
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
Class to define colors available for display functionnalities.
Definition: vpColor.h:123
VISP_EXPORT vpImagePoint operator*(const vpImagePoint &ip1, const double scale)
Definition: vpImagePoint.h:468
virtual void display(const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpColor &color=vpColor::green, const unsigned int thickness=1)=0
double get_oY() const
Get the point Y coordinate in the object frame.
Definition: vpPoint.h:136
void set_x(const double x)
Set the point x coordinate in the image plane.
Definition: vpPoint.h:183
virtual void init()=0
double get_y() const
Get the point y coordinate in the image plane.
Definition: vpPoint.h:145
double get_w() const
Get the point w coordinate in the image plane.
Definition: vpPoint.h:147
void set_X(const double X)
Set the point X coordinate in the camera frame.
Definition: vpPoint.h:165
static const vpColor green
Definition: vpColor.h:168
void changeFrame(const vpHomogeneousMatrix &cMo)
Definition: vpPoint.h:87
double get_W() const
Get the point W coordinate in the camera frame.
Definition: vpPoint.h:131
void set_oX(const double X)
Set the point X coordinate in the object frame.
Definition: vpPoint.h:174
Class that defines what is a point.
Definition: vpPoint.h:65
virtual void projection()=0
This class aims to compute the homography wrt.two images.
Definition: vpHomography.h:174
virtual ~vpPoint()
Destructor.
Definition: vpPoint.h:72
void set_Z(const double Z)
Set the point Z coordinate in the camera frame.
Definition: vpPoint.h:169
void set_oZ(const double Z)
Set the point Z coordinate in the object frame.
Definition: vpPoint.h:178
void projection()
Definition: vpPoint.h:208
void set_W(const double W)
Set the point W coordinate in the camera frame.
Definition: vpPoint.h:171
Class that defines what is a generic geometric feature.
virtual void setWorldCoordinates(const vpColVector &oP)=0
Generic class defining intrinsic camera parameters.
double get_oZ() const
Get the point Z coordinate in the object frame.
Definition: vpPoint.h:138
void set_oW(const double W)
Set the point W coordinate in the object frame.
Definition: vpPoint.h:180
void set_y(const double y)
Set the point y coordinate in the image plane.
Definition: vpPoint.h:185
void set_Y(const double Y)
Set the point Y coordinate in the camera frame.
Definition: vpPoint.h:167
void set_w(const double w)
Set the point w coordinate in the image plane.
Definition: vpPoint.h:187
double get_x() const
Get the point x coordinate in the image plane.
Definition: vpPoint.h:143
double get_Y() const
Get the point Y coordinate in the camera frame.
Definition: vpPoint.h:127
double get_Z() const
Get the point Z coordinate in the camera frame.
Definition: vpPoint.h:129
double get_oX() const
Get the point X coordinate in the object frame.
Definition: vpPoint.h:134
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
double get_oW() const
Get the point W coordinate in the object frame.
Definition: vpPoint.h:140
virtual vpForwardProjection * duplicate() const =0
void set_oY(const double Y)
Set the point Y coordinate in the object frame.
Definition: vpPoint.h:176