MRPT  2.0.5
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-2020, 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 */
31  std::string m_id;
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 */
54  CDetectable2D(int x = 0, int y = 0, int height = 0, int width = 0)
55  : m_x(x), m_y(y), m_height(height), m_width(width){};
56 
57  /** Copy pointer content constructor */
58  CDetectable2D(const CDetectable2D* d) { *this = *d; };
59  /** Compute distance between centers of two detectable 2D objects.
60  * \return calculated distance.
61  */
62  inline double distanceTo(const CDetectable2D& d2)
63  {
64  // Calculate objects centers
65  double c_x1 = (m_x + m_width / 2);
66  double c_x2 = (d2.m_x + d2.m_width / 2);
67  double c_y1 = (m_y + m_height / 2);
68  double c_y2 = (d2.m_y + d2.m_height / 2);
69 
70  return std::sqrt(std::pow(c_x1 - c_x2, 2) + pow(c_y1 - c_y2, 2));
71  };
72 };
73 
75 {
77 
78  public:
79  CDetectable3D() = default;
80 
81  CDetectable3D(const CDetectable2D::Ptr& object2d);
82 
83  /** Copy pointer content constructor */
84  CDetectable3D(const CDetectable3D* d) { *this = *d; };
85  /** Z coordinate of detected object */
86  float m_z;
87 
88 }; // End of class
89 } // namespace mrpt::detectors
float m_height
Size of detected object.
double distanceTo(const CDetectable2D &d2)
Compute distance between centers of two detectable 2D objects.
CDetectable2D(int x=0, int y=0, int height=0, int width=0)
Extra constructor.
float m_z
Z coordinate of detected object.
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.
std::string m_id
Must be an unique id for each detectable object.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:30
float m_x
2D Coordinates of detected object
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Base class that contains common atributes and functions of detectable objects.



Page generated by Doxygen 1.8.14 for MRPT 2.0.5 Git: ecc95703f Thu Jul 2 07:56:41 2020 +0200 at jue jul 2 08:00:14 CEST 2020