Main MRPT website > C++ reference for MRPT 1.9.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-2018, 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 #include <cmath>
16 
17 namespace mrpt
18 {
19 namespace detectors
20 {
21 /** Base class that contains common atributes and functions of detectable
22  * objects.
23  * It was initially thought for detected objects in images from cams, but it's
24  * easily
25  * expandable to other source types (f.i. scanners).
26  * \ingroup mrpt_detectors_grp
27  */
29 {
31 
32  public:
33  /** Must be an unique id for each detectable object */
35 
36  /** Observation wich contain the deteted object */
38 
40  {
41  obs = newObs;
42  };
43 
44 }; // End of class
45 
47 {
49 
50  public:
51  /** 2D Coordinates of detected object */
52  float m_x, m_y;
53  /** Size of detected object */
54  float m_height, m_width;
55 
56  /** Extra constructor */
58  const int& x = 0, const int& y = 0, const int& height = 0,
59  const int& width = 0)
60  : m_x(x), m_y(y), m_height(height), m_width(width){};
61 
62  /** Copy pointer content constructor */
63  CDetectable2D(const CDetectable2D* d) { *this = *d; };
64  /** Compute distance between centers of two detectable 2D objects.
65  * \return calculated distance.
66  */
67  inline double distanceTo(const CDetectable2D& d2)
68  {
69  // Calculate objects centers
70  double c_x1 = (m_x + m_width / 2);
71  double c_x2 = (d2.m_x + d2.m_width / 2);
72  double c_y1 = (m_y + m_height / 2);
73  double c_y2 = (d2.m_y + d2.m_height / 2);
74 
75  return std::sqrt(std::pow(c_x1 - c_x2, 2) + pow(c_y1 - c_y2, 2));
76  };
77 };
78 
80 {
82 
83  public:
85 
86  CDetectable3D(const CDetectable2D::Ptr& object2d);
87 
88  /** Copy pointer content constructor */
89  CDetectable3D(const CDetectable3D* d) { *this = *d; };
90  /** Z coordinate of detected object */
91  float m_z;
92 
93 }; // End of class
94 }
95 }
96 
97 #endif
mrpt::detectors::CDetectableObject::obs
mrpt::obs::CObservation::Ptr obs
Observation wich contain the deteted object.
Definition: CDetectableObject.h:37
mrpt::obs::CObservation::Ptr
std::shared_ptr< CObservation > Ptr
Definition: CObservation.h:45
mrpt::detectors::CDetectable2D::distanceTo
double distanceTo(const CDetectable2D &d2)
Compute distance between centers of two detectable 2D objects.
Definition: CDetectableObject.h:67
mrpt::detectors::CDetectable3D::m_z
float m_z
Z coordinate of detected object.
Definition: CDetectableObject.h:89
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::detectors::CDetectable2D::m_x
float m_x
2D Coordinates of detected object
Definition: CDetectableObject.h:52
mrpt::detectors::CDetectableObject::m_id
std::string m_id
Must be an unique id for each detectable object.
Definition: CDetectableObject.h:34
mrpt::detectors::CDetectable2D::m_width
float m_width
Definition: CDetectableObject.h:54
mrpt::detectors::CDetectable2D::CDetectable2D
CDetectable2D(const int &x=0, const int &y=0, const int &height=0, const int &width=0)
Extra constructor.
Definition: CDetectableObject.h:57
mrpt::serialization::CSerializable
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:32
mrpt::detectors::CDetectable2D::Ptr
std::shared_ptr< CDetectable2D > Ptr
Definition: CDetectableObject.h:48
mrpt::detectors::CDetectableObject::setObservation
void setObservation(mrpt::obs::CObservation::Ptr newObs)
Definition: CDetectableObject.h:39
DEFINE_VIRTUAL_SERIALIZABLE
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
Definition: CSerializable.h:119
height
GLenum GLsizei GLsizei height
Definition: glext.h:3554
mrpt::detectors::CDetectable2D
Definition: CDetectableObject.h:46
mrpt::detectors::CDetectable3D
Definition: CDetectableObject.h:79
mrpt::detectors::CDetectable2D::CDetectable2D
CDetectable2D(const CDetectable2D *d)
Copy pointer content constructor.
Definition: CDetectableObject.h:63
mrpt::detectors::CDetectable2D::m_y
float m_y
Definition: CDetectableObject.h:52
CObservation.h
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
width
GLenum GLsizei width
Definition: glext.h:3531
mrpt::detectors::CDetectable2D::m_height
float m_height
Size of detected object.
Definition: CDetectableObject.h:54
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::detectors::CDetectableObject
Base class that contains common atributes and functions of detectable objects.
Definition: CDetectableObject.h:28
CSerializable.h
mrpt::detectors::CDetectable3D::CDetectable3D
CDetectable3D()
Definition: CDetectableObject.h:84
y
GLenum GLint GLint y
Definition: glext.h:3538
x
GLenum GLint x
Definition: glext.h:3538



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST