Main MRPT website > C++ reference for MRPT 1.5.9
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-2017, 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  */
31  class DETECTORS_IMPEXP CDetectableObject: public mrpt::utils::CSerializable
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 
48 
50  {
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 */
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 
88 
90  {
92 
93  public:
94 
96 
97  CDetectable3D( const CDetectable2DPtr &object2d );
98 
99  /** Copy pointer content constructor */
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.
mrpt::obs::CObservationPtr obs
Observation wich contain the deteted object.
GLenum GLsizei width
Definition: glext.h:3513
#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...
CDetectable2D(const CDetectable2D *d)
Copy pointer content constructor.
float m_y
2D Coordinates of detected object
void setObservation(mrpt::obs::CObservationPtr newObs)
GLsizei const GLchar ** string
Definition: glext.h:3919
std::string m_id
Must be an unique id for each detectable 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.
GLenum GLint GLint y
Definition: glext.h:3516
CDetectable2D(const int &x=0, const int &y=0, const int &height=0, const int &width=0)
Extra constructor.
GLenum GLint x
Definition: glext.h:3516
GLenum GLsizei GLsizei height
Definition: glext.h:3523
#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.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020