Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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
15#define _USE_MATH_DEFINES // (For VS to define M_PI, etc. in cmath)
16#include <cmath>
17
19
20namespace 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
44 DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE( CDetectableObject, mrpt::utils::CSerializable, DETECTORS_IMPEXP )
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
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
#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...
float m_y
2D Coordinates of detected object
double distanceTo(const CDetectable2D &d2)
Compute distance between centers of two detectable 2D objects.
CDetectable2D(const CDetectable2D *d)
Copy pointer content constructor.
float m_width
Size of detected object.
CDetectable2D(const int &x=0, const int &y=0, const int &height=0, const int &width=0)
Extra constructor.
float m_z
Z coordinate of detected object.
CDetectable3D(const CDetectable3D *d)
Copy pointer content constructor.
CDetectable3D(const CDetectable2DPtr &object2d)
Base class that contains common atributes and functions of detectable objects.
mrpt::obs::CObservationPtr obs
Observation wich contain the deteted object.
void setObservation(mrpt::obs::CObservationPtr newObs)
std::string m_id
Must be an unique id for each detectable object.
struct DETECTORS_IMPEXP CDetectable2DPtr
struct OBS_IMPEXP CObservationPtr
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.9.5 for MRPT 1.4.0 SVN: at Sun Nov 27 02:56:59 UTC 2022