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::detectors
18 {
19 /** Base class that contains common atributes and functions of detectable
20  * objects.
21  * It was initially thought for detected objects in images from cams, but it's
22  * easily
23  * expandable to other source types (f.i. scanners).
24  * \ingroup mrpt_detectors_grp
25  */
27 {
29 
30  public:
31  /** Must be an unique id for each detectable object */
33 
34  /** Observation wich contain the deteted object */
36 
38  {
39  obs = newObs;
40  };
41 
42 }; // End of class
43 
45 {
47 
48  public:
49  /** 2D Coordinates of detected object */
50  float m_x, m_y;
51  /** Size of detected object */
52  float m_height, m_width;
53 
54  /** Extra constructor */
56  const int& x = 0, const int& y = 0, const int& height = 0,
57  const int& width = 0)
58  : m_x(x), m_y(y), m_height(height), m_width(width){};
59 
60  /** Copy pointer content constructor */
61  CDetectable2D(const CDetectable2D* d) { *this = *d; };
62  /** Compute distance between centers of two detectable 2D objects.
63  * \return calculated distance.
64  */
65  inline double distanceTo(const CDetectable2D& d2)
66  {
67  // Calculate objects centers
68  double c_x1 = (m_x + m_width / 2);
69  double c_x2 = (d2.m_x + d2.m_width / 2);
70  double c_y1 = (m_y + m_height / 2);
71  double c_y2 = (d2.m_y + d2.m_height / 2);
72 
73  return std::sqrt(std::pow(c_x1 - c_x2, 2) + pow(c_y1 - c_y2, 2));
74  };
75 };
76 
78 {
80 
81  public:
83 
84  CDetectable3D(const CDetectable2D::Ptr& object2d);
85 
86  /** Copy pointer content constructor */
87  CDetectable3D(const CDetectable3D* d) { *this = *d; };
88  /** Z coordinate of detected object */
89  float m_z;
90 
91 }; // End of class
92 }
93 #endif
94 
95 
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.
#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:30
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020