MRPT  1.9.9
CDetectableObject.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <mrpt/obs/CObservation.h>
14 #include <cmath>
15 
16 namespace mrpt::detectors
17 {
18 /** Base class that contains common atributes and functions of detectable
19  * objects.
20  * It was initially thought for detected objects in images from cams, but it's
21  * easily
22  * expandable to other source types (f.i. scanners).
23  * \ingroup mrpt_detectors_grp
24  */
26 {
28 
29  public:
30  /** Must be an unique id for each detectable object */
32 
33  /** Observation wich contain the deteted object */
35 
37  {
38  obs = newObs;
39  };
40 
41 }; // End of class
42 
44 {
46 
47  public:
48  /** 2D Coordinates of detected object */
49  float m_x, m_y;
50  /** Size of detected object */
51  float m_height, m_width;
52 
53  /** Extra constructor */
55  const int& x = 0, const int& y = 0, const int& height = 0,
56  const int& width = 0)
57  : m_x(x), m_y(y), m_height(height), m_width(width){};
58 
59  /** Copy pointer content constructor */
60  CDetectable2D(const CDetectable2D* d) { *this = *d; };
61  /** Compute distance between centers of two detectable 2D objects.
62  * \return calculated distance.
63  */
64  inline double distanceTo(const CDetectable2D& d2)
65  {
66  // Calculate objects centers
67  double c_x1 = (m_x + m_width / 2);
68  double c_x2 = (d2.m_x + d2.m_width / 2);
69  double c_y1 = (m_y + m_height / 2);
70  double c_y2 = (d2.m_y + d2.m_height / 2);
71 
72  return std::sqrt(std::pow(c_x1 - c_x2, 2) + pow(c_y1 - c_y2, 2));
73  };
74 };
75 
77 {
79 
80  public:
81  CDetectable3D() = default;
82 
83  CDetectable3D(const CDetectable2D::Ptr& object2d);
84 
85  /** Copy pointer content constructor */
86  CDetectable3D(const CDetectable3D* d) { *this = *d; };
87  /** Z coordinate of detected object */
88  float m_z;
89 
90 }; // End of class
91 } // namespace mrpt::detectors
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:3535
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:4116
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:3542
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:3542
GLenum GLsizei GLsizei height
Definition: glext.h:3558
Base class that contains common atributes and functions of detectable objects.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019