Main MRPT website
>
C++ reference
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
mrpt
detectors
CDetectableObject.h
Go to the documentation of this file.
1
/* +---------------------------------------------------------------------------+
2
| The Mobile Robot Programming Toolkit (MRPT) C++ library |
3
| |
4
| http://www.mrpt.org/ |
5
| |
6
| Copyright (C) 2005-2012 University of Malaga |
7
| |
8
| This software was written by the Machine Perception and Intelligent |
9
| Robotics Lab, University of Malaga (Spain). |
10
| Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11
| |
12
| This file is part of the MRPT project. |
13
| |
14
| MRPT is free software: you can redistribute it and/or modify |
15
| it under the terms of the GNU General Public License as published by |
16
| the Free Software Foundation, either version 3 of the License, or |
17
| (at your option) any later version. |
18
| |
19
| MRPT is distributed in the hope that it will be useful, |
20
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
| GNU General Public License for more details. |
23
| |
24
| You should have received a copy of the GNU General Public License |
25
| along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26
| |
27
+---------------------------------------------------------------------------+ */
28
29
#ifndef CDetectableObject_H
30
#define CDetectableObject_H
31
32
#include <
mrpt/utils/CSerializable.h
>
33
#include <
mrpt/slam/CObservation.h
>
34
35
#include <
mrpt/detectors/link_pragmas.h
>
36
37
namespace
mrpt
38
{
39
namespace
detectors
40
{
41
using namespace
mrpt::slam;
42
43
DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE
(
CDetectableObject
,
mrpt::utils::CSerializable
,
DETECTORS_IMPEXP
)
44
45
/** Base class that contains common atributes and functions of detectable objects.
46
* It was initially thought for detected objects in images from cams, but it's easily
47
* expandable to other source types (f.i. scanners).
48
* \ingroup mrpt_detectors_grp
49
*/
50
class
DETECTORS_IMPEXP
CDetectableObject
: public mrpt::utils::
CSerializable
51
{
52
DEFINE_VIRTUAL_SERIALIZABLE
(
CDetectableObject
)
53
54
public:
55
56
std::
string
m_id;
//!< Must be an unique id for each detectable object
57
58
CObservationPtr
obs;
//!< Observation wich contain the deteted object
59
60
inline
void
setObservation(
CObservationPtr
newObs ){ obs = newObs; };
61
62
};
// End of class
63
64
65
DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE
(
CDetectable2D
,
mrpt::detectors::CDetectableObject
,
DETECTORS_IMPEXP
)
66
67
class
DETECTORS_IMPEXP
CDetectable2D
: public
CDetectableObject
68
{
69
DEFINE_SERIALIZABLE
(
CDetectable2D
)
70
71
public:
72
73
float
m_x, m_y;
//!< 2D Coordinates of detected object
74
float
m_height, m_width;
//!< Size of detected object
75
76
/** Extra constructor */
77
CDetectable2D
( const
int
&x = 0, const
int
&y = 0, const
int
&height = 0, const
int
&width = 0 )
78
: m_x(x), m_y(y), m_height(height), m_width(width)
79
{};
80
81
/** Copy pointer content constructor */
82
CDetectable2D
(
const
CDetectable2D
*d )
83
{
84
*
this
= *d;
85
};
86
87
/** Compute distance between centers of two detectable 2D objects.
88
* \return calculated distance.
89
*/
90
inline
double
distanceTo(
const
CDetectable2D
&d2 )
91
{
92
// Calculate objects centers
93
double
c_x1 = ( m_x + m_width/2 );
94
double
c_x2 = ( d2.
m_x
+ d2.
m_width
/2 );
95
double
c_y1 = ( m_y + m_height/2 ) ;
96
double
c_y2 = ( d2.
m_y
+ d2.
m_height
/2 ) ;
97
98
return
sqrt( pow( c_x1 - c_x2, 2 ) + pow( c_y1 - c_y2, 2 ) );
99
};
100
101
};
102
103
104
DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE
(
CDetectable3D
,
mrpt::detectors::CDetectable2D
,
DETECTORS_IMPEXP
)
105
106
class
DETECTORS_IMPEXP
CDetectable3D
: public
CDetectable2D
107
{
108
DEFINE_SERIALIZABLE
(
CDetectable3D
)
109
110
public:
111
112
CDetectable3D
(){};
113
114
CDetectable3D
(
const
CDetectable2DPtr
&object2d )
115
: CDetectable2D( object2d.pointer() ), m_z(0)
116
{ };
117
118
/** Copy pointer content constructor */
119
CDetectable3D
(
const
CDetectable3D
*d )
120
{
121
*
this
= *d;
122
};
123
124
125
float
m_z;
//!< Z coordinate of detected object
126
127
};
// End of class
128
}
129
130
}
131
132
#endif
Page generated by
Doxygen 1.8.3
for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013