Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
ml
branch_estimator.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2010-2011, Willow Garage, Inc.
6
*
7
* All rights reserved.
8
*
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions
11
* are met:
12
*
13
* * Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
15
* * Redistributions in binary form must reproduce the above
16
* copyright notice, this list of conditions and the following
17
* disclaimer in the documentation and/or other materials provided
18
* with the distribution.
19
* * Neither the name of Willow Garage, Inc. nor the names of its
20
* contributors may be used to endorse or promote products derived
21
* from this software without specific prior written permission.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
* POSSIBILITY OF SUCH DAMAGE.
35
*
36
*/
37
38
#pragma once
39
40
#include <
pcl/common/common.h
>
41
#include <pcl/common/utils.h>
// pcl::utils::ignore
42
#include <pcl/ml/stats_estimator.h>
43
44
namespace
pcl
{
45
46
/** Interface for branch estimators. */
47
class
PCL_EXPORTS
BranchEstimator
{
48
public
:
49
/** Destructor. */
50
virtual
~BranchEstimator
() =
default
;
51
52
/** Returns the number of branches the corresponding tree has. */
53
virtual
std::size_t
54
getNumOfBranches
()
const
= 0;
55
56
/** Computes the branch index for the specified result.
57
*
58
* \param[in] result the result the branch index will be computed for
59
* \param[in] flag the flag corresponding to the specified result
60
* \param[in] threshold the threshold used to compute the branch index
61
* \param[out] branch_index the destination for the computed branch index
62
*/
63
virtual
void
64
computeBranchIndex
(
const
float
result,
65
const
unsigned
char
flag,
66
const
float
threshold,
67
unsigned
char
& branch_index)
const
= 0;
68
};
69
70
/** Branch estimator for binary trees where the branch is computed only from the
71
* threshold. */
72
class
PCL_EXPORTS
BinaryTreeThresholdBasedBranchEstimator
:
public
BranchEstimator
{
73
public
:
74
/** Constructor. */
75
inline
BinaryTreeThresholdBasedBranchEstimator
() =
default
;
76
/** Destructor. */
77
inline
~BinaryTreeThresholdBasedBranchEstimator
()
override
=
default
;
78
79
/** Returns the number of branches the corresponding tree has. */
80
inline
std::size_t
81
getNumOfBranches
()
const override
82
{
83
return
2;
84
}
85
86
/** Computes the branch index for the specified result.
87
*
88
* \param[in] result the result the branch index will be computed for
89
* \param[in] flag the flag corresponding to the specified result
90
* \param[in] threshold the threshold used to compute the branch index
91
* \param[out] branch_index the destination for the computed branch index
92
*/
93
inline
void
94
computeBranchIndex
(
const
float
result,
95
const
unsigned
char
flag,
96
const
float
threshold,
97
unsigned
char
& branch_index)
const override
98
{
99
pcl::utils::ignore
(flag);
100
branch_index = (result > threshold) ? 1 : 0;
101
}
102
};
103
104
/** Branch estimator for ternary trees where one branch is used for missing data
105
* (indicated by flag != 0). */
106
class
PCL_EXPORTS
TernaryTreeMissingDataBranchEstimator
:
public
BranchEstimator
{
107
public
:
108
/** Constructor. */
109
inline
TernaryTreeMissingDataBranchEstimator
() =
default
;
110
/** Destructor. */
111
inline
~TernaryTreeMissingDataBranchEstimator
()
override
=
default
;
112
113
/** \brief Returns the number of branches the corresponding tree has. */
114
inline
std::size_t
115
getNumOfBranches
()
const override
116
{
117
return
3;
118
}
119
120
/** Computes the branch index for the specified result.
121
*
122
* \param[in] result the result the branch index will be computed for
123
* \param[in] flag the flag corresponding to the specified result
124
* \param[in] threshold the threshold used to compute the branch index
125
* \param[out] branch_index the destination for the computed branch index
126
*/
127
inline
void
128
computeBranchIndex
(
const
float
result,
129
const
unsigned
char
flag,
130
const
float
threshold,
131
unsigned
char
& branch_index)
const override
132
{
133
if
(flag == 0)
134
branch_index = (result > threshold) ? 1 : 0;
135
else
136
branch_index = 2;
137
}
138
};
139
140
}
// namespace pcl
pcl::BinaryTreeThresholdBasedBranchEstimator::computeBranchIndex
void computeBranchIndex(const float result, const unsigned char flag, const float threshold, unsigned char &branch_index) const override
Computes the branch index for the specified result.
Definition
branch_estimator.h:94
pcl::BinaryTreeThresholdBasedBranchEstimator::getNumOfBranches
std::size_t getNumOfBranches() const override
Returns the number of branches the corresponding tree has.
Definition
branch_estimator.h:81
pcl::BinaryTreeThresholdBasedBranchEstimator::BinaryTreeThresholdBasedBranchEstimator
BinaryTreeThresholdBasedBranchEstimator()=default
Constructor.
pcl::BinaryTreeThresholdBasedBranchEstimator::~BinaryTreeThresholdBasedBranchEstimator
~BinaryTreeThresholdBasedBranchEstimator() override=default
Destructor.
pcl::BranchEstimator
Interface for branch estimators.
Definition
branch_estimator.h:47
pcl::BranchEstimator::getNumOfBranches
virtual std::size_t getNumOfBranches() const =0
Returns the number of branches the corresponding tree has.
pcl::BranchEstimator::computeBranchIndex
virtual void computeBranchIndex(const float result, const unsigned char flag, const float threshold, unsigned char &branch_index) const =0
Computes the branch index for the specified result.
pcl::BranchEstimator::~BranchEstimator
virtual ~BranchEstimator()=default
Destructor.
pcl::TernaryTreeMissingDataBranchEstimator::getNumOfBranches
std::size_t getNumOfBranches() const override
Returns the number of branches the corresponding tree has.
Definition
branch_estimator.h:115
pcl::TernaryTreeMissingDataBranchEstimator::TernaryTreeMissingDataBranchEstimator
TernaryTreeMissingDataBranchEstimator()=default
Constructor.
pcl::TernaryTreeMissingDataBranchEstimator::computeBranchIndex
void computeBranchIndex(const float result, const unsigned char flag, const float threshold, unsigned char &branch_index) const override
Computes the branch index for the specified result.
Definition
branch_estimator.h:128
pcl::TernaryTreeMissingDataBranchEstimator::~TernaryTreeMissingDataBranchEstimator
~TernaryTreeMissingDataBranchEstimator() override=default
Destructor.
common.h
Define standard C methods and C++ classes that are common to all methods.
pcl::utils::ignore
void ignore(const T &...)
Utility function to eliminate unused variable warnings.
Definition
utils.h:62
pcl
Definition
convolution.h:46