Main MRPT website > C++ reference for MRPT 1.3.2
CDetectableObject.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2015, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #ifndef CDetectableObject_H
11 #define CDetectableObject_H
12 
14 #include <mrpt/obs/CObservation.h>
15 #define _USE_MATH_DEFINES // (For VS to define M_PI, etc. in cmath)
16 #include <cmath>
17 
19 
20 namespace mrpt
21 {
22  namespace detectors
23  {
25 
26  /** Base class that contains common atributes and functions of detectable objects.
27  * It was initially thought for detected objects in images from cams, but it's easily
28  * expandable to other source types (f.i. scanners).
29  * \ingroup mrpt_detectors_grp
30  */
32  {
34 
35  public:
36 
37  std::string m_id; //!< Must be an unique id for each detectable object
38 
39  mrpt::obs::CObservationPtr obs; //!< Observation wich contain the deteted object
40 
41  inline void setObservation( mrpt::obs::CObservationPtr newObs ){ obs = newObs; };
42 
43  }; // End of class
45 
46 
47  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CDetectable2D, mrpt::detectors::CDetectableObject, DETECTORS_IMPEXP )
48 
49  class DETECTORS_IMPEXP CDetectable2D: public CDetectableObject
50  {
51  DEFINE_SERIALIZABLE( CDetectable2D )
52 
53  public:
54 
55  float m_x, m_y; //!< 2D Coordinates of detected object
56  float m_height, m_width; //!< Size of detected object
57 
58  /** Extra constructor */
59  CDetectable2D( const int &x = 0, const int &y = 0, const int &height = 0, const int &width = 0 )
60  : m_x(x), m_y(y), m_height(height), m_width(width)
61  {};
62 
63  /** Copy pointer content constructor */
64  CDetectable2D( const CDetectable2D *d )
65  {
66  *this = *d;
67  };
68 
69  /** Compute distance between centers of two detectable 2D objects.
70  * \return calculated distance.
71  */
72  inline double distanceTo( const CDetectable2D &d2 )
73  {
74  // Calculate objects centers
75  double c_x1 = ( m_x + m_width/2 );
76  double c_x2 = ( d2.m_x + d2.m_width/2 );
77  double c_y1 = ( m_y + m_height/2 ) ;
78  double c_y2 = ( d2.m_y + d2.m_height/2 ) ;
79 
80  return std::sqrt( std::pow( c_x1 - c_x2, 2 ) + pow( c_y1 - c_y2, 2 ) );
81  };
82 
83  };
85 
86 
87  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CDetectable3D, mrpt::detectors::CDetectable2D, DETECTORS_IMPEXP )
88 
89  class DETECTORS_IMPEXP CDetectable3D: public CDetectable2D
90  {
91  DEFINE_SERIALIZABLE( CDetectable3D )
92 
93  public:
94 
95  CDetectable3D(){};
96 
97  CDetectable3D( const CDetectable2DPtr &object2d );
98 
99  /** Copy pointer content constructor */
100  CDetectable3D( const CDetectable3D *d )
101  {
102  *this = *d;
103  };
104 
105 
106  float m_z; //!< Z coordinate of detected object
107 
108  }; // End of class
110  }
111 
112 }
113 
114 #endif
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
double distanceTo(const CDetectable2D &d2)
Compute distance between centers of two detectable 2D objects.
STL namespace.
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
float m_width
Size of detected object.
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
class BASE_IMPEXP CSerializable
Definition: CStream.h:23
CDetectable2D(const CDetectable2D *d)
Copy pointer content constructor.
float m_y
2D Coordinates of detected object
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
CDetectable3D(const CDetectable3D *d)
Copy pointer content constructor.
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
Base class that contains common atributes and functions of detectable objects.



Page generated by Doxygen 1.8.9.1 for MRPT 1.3.2 SVN:Unversioned directory at Thu Dec 10 00:07:55 UTC 2015