ViSP  2.10.0
vpPoint.h
1 /****************************************************************************
2  *
3  * $Id: vpPoint.h 4574 2014-01-09 08:48:51Z 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  * 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 
116  // Get coordinates
118  double get_X() const { return cP[0] ; }
120  double get_Y() const { return cP[1] ; }
122  double get_Z() const { return cP[2] ; }
124  double get_W() const { return cP[3] ; }
125 
127  double get_oX() const { return oP[0] ; }
129  double get_oY() const { return oP[1] ; }
131  double get_oZ() const { return oP[2] ; }
133  double get_oW() const { return oP[3] ; }
134 
136  double get_x() const { return p[0] ; }
138  double get_y() const { return p[1] ; }
140  double get_w() const { return p[2] ; }
141 
143  void getWorldCoordinates(double& ox,
144  double& oy,
145  double& oz) ;
147  void getWorldCoordinates(vpColVector &_oP) ;
148  vpColVector getWorldCoordinates(void) ;
149 
151  void init() ;
152 
153  friend VISP_EXPORT std::ostream& operator<<(std::ostream& os, vpPoint& vpp);
154  vpPoint& operator=(const vpPoint& vpp);
155 
157  void projection(const vpColVector &_cP, vpColVector &_p) ;
158 
167  inline void projection() {
168  double d = 1/cP[2] ;
169  p[0] = cP[0]*d ;
170  p[1] = cP[1]*d ;
171  p[2] = 1 ;
172  }
173 
174  // Set coordinates
176  inline void set_X(const double X) { cP[0] = X ; }
178  inline void set_Y(const double Y) { cP[1] = Y ; }
180  inline void set_Z(const double Z) { cP[2] = Z ; }
182  inline void set_W(const double W) { cP[3] = W ; }
183 
185  inline void set_oX(const double X) { oP[0] = X ; }
187  inline void set_oY(const double Y) { oP[1] = Y ; }
189  inline void set_oZ(const double Z) { oP[2] = Z ; }
191  inline void set_oW(const double W) { oP[3] = W ; }
192 
194  inline void set_x(const double x) { p[0] = x ; }
196  inline void set_y(const double y) { p[1] = y ; }
198  inline void set_w(const double w) { p[2] = w ; }
199 
201  void setWorldCoordinates(const double ox,
202  const double oy,
203  const double oz) ;
205  void setWorldCoordinates(const vpColVector &_oP) ;
206 } ;
207 
208 const vpPoint VISP_EXPORT operator*(const vpHomogeneousMatrix &M, const vpPoint& p) ;
209 const vpPoint VISP_EXPORT operator*(const vpHomography &H, const vpPoint& p) ;
210 
211 #endif
vpTracker & operator=(const vpTracker &tracker)
Copy operator.
Definition: vpTracker.cpp:69
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:125
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:129
void set_x(const double x)
Set the point x coordinate in the image plane.
Definition: vpPoint.h:194
virtual void init()=0
double get_y() const
Get the point y coordinate in the image plane.
Definition: vpPoint.h:138
double get_w() const
Get the point w coordinate in the image plane.
Definition: vpPoint.h:140
void set_X(const double X)
Set the point X coordinate in the camera frame.
Definition: vpPoint.h:176
static const vpColor green
Definition: vpColor.h:170
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:124
void set_oX(const double X)
Set the point X coordinate in the object frame.
Definition: vpPoint.h:185
Class that defines what is a point.
Definition: vpPoint.h:65
vpColVector operator*(const double &x, const vpColVector &B)
multiplication by a scalar Ci = x*Bi
virtual void projection()=0
This class aims to compute the homography wrt.two images.
Definition: vpHomography.h:178
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:180
void set_oZ(const double Z)
Set the point Z coordinate in the object frame.
Definition: vpPoint.h:189
void projection()
Definition: vpPoint.h:167
void set_W(const double W)
Set the point W coordinate in the camera frame.
Definition: vpPoint.h:182
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:131
void set_oW(const double W)
Set the point W coordinate in the object frame.
Definition: vpPoint.h:191
void set_y(const double y)
Set the point y coordinate in the image plane.
Definition: vpPoint.h:196
void set_Y(const double Y)
Set the point Y coordinate in the camera frame.
Definition: vpPoint.h:178
void set_w(const double w)
Set the point w coordinate in the image plane.
Definition: vpPoint.h:198
double get_x() const
Get the point x coordinate in the image plane.
Definition: vpPoint.h:136
double get_Y() const
Get the point Y coordinate in the camera frame.
Definition: vpPoint.h:120
double get_Z() const
Get the point Z coordinate in the camera frame.
Definition: vpPoint.h:122
double get_oX() const
Get the point X coordinate in the object frame.
Definition: vpPoint.h:127
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_X() const
Get the point X coordinate in the camera frame.
Definition: vpPoint.h:118
double get_oW() const
Get the point W coordinate in the object frame.
Definition: vpPoint.h:133
virtual vpForwardProjection * duplicate() const =0
void set_oY(const double Y)
Set the point Y coordinate in the object frame.
Definition: vpPoint.h:187