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
float m_height
Size of detected object.
double distanceTo(const CDetectable2D &d2)
Compute distance between centers of two detectable 2D objects.
float m_z
Z coordinate of detected object.
GLenum GLsizei width
Definition: glext.h:3531
mrpt::obs::CObservation::Ptr obs
Observation wich contain the deteted object.
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
void setObservation(mrpt::obs::CObservation::Ptr newObs)
CDetectable2D(const CDetectable2D *d)
Copy pointer content constructor.
GLsizei const GLchar ** string
Definition: glext.h:4101
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...
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:32
GLenum GLint GLint y
Definition: glext.h:3538
float m_x
2D Coordinates of detected object
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:3538
GLenum GLsizei GLsizei height
Definition: glext.h:3554
Base class that contains common atributes and functions of detectable objects.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019