Point Cloud Library (PCL)
1.12.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
#include <istream>
45
#include <ostream>
46
47
namespace
pcl
{
48
49
/** Interface for branch estimators. */
50
class
PCL_EXPORTS
BranchEstimator
{
51
public
:
52
/** Destructor. */
53
virtual
~BranchEstimator
() {}
54
55
/** Returns the number of branches the corresponding tree has. */
56
virtual
std::size_t
57
getNumOfBranches
()
const
= 0;
58
59
/** Computes the branch index for the specified result.
60
*
61
* \param[in] result the result the branch index will be computed for
62
* \param[in] flag the flag corresponding to the specified result
63
* \param[in] threshold the threshold used to compute the branch index
64
* \param[out] branch_index the destination for the computed branch index
65
*/
66
virtual
void
67
computeBranchIndex
(
const
float
result,
68
const
unsigned
char
flag,
69
const
float
threshold,
70
unsigned
char
& branch_index)
const
= 0;
71
};
72
73
/** Branch estimator for binary trees where the branch is computed only from the
74
* threshold. */
75
class
PCL_EXPORTS
BinaryTreeThresholdBasedBranchEstimator
:
public
BranchEstimator
{
76
public
:
77
/** Constructor. */
78
inline
BinaryTreeThresholdBasedBranchEstimator
() {}
79
/** Destructor. */
80
inline
~BinaryTreeThresholdBasedBranchEstimator
() {}
81
82
/** Returns the number of branches the corresponding tree has. */
83
inline
std::size_t
84
getNumOfBranches
()
const override
85
{
86
return
2;
87
}
88
89
/** Computes the branch index for the specified result.
90
*
91
* \param[in] result the result the branch index will be computed for
92
* \param[in] flag the flag corresponding to the specified result
93
* \param[in] threshold the threshold used to compute the branch index
94
* \param[out] branch_index the destination for the computed branch index
95
*/
96
inline
void
97
computeBranchIndex
(
const
float
result,
98
const
unsigned
char
flag,
99
const
float
threshold,
100
unsigned
char
& branch_index)
const override
101
{
102
pcl::utils::ignore
(flag);
103
branch_index = (result > threshold) ? 1 : 0;
104
}
105
};
106
107
/** Branch estimator for ternary trees where one branch is used for missing data
108
* (indicated by flag != 0). */
109
class
PCL_EXPORTS
TernaryTreeMissingDataBranchEstimator
:
public
BranchEstimator
{
110
public
:
111
/** Constructor. */
112
inline
TernaryTreeMissingDataBranchEstimator
() {}
113
/** Destructor. */
114
inline
~TernaryTreeMissingDataBranchEstimator
() {}
115
116
/** \brief Returns the number of branches the corresponding tree has. */
117
inline
std::size_t
118
getNumOfBranches
()
const override
119
{
120
return
3;
121
}
122
123
/** Computes the branch index for the specified result.
124
*
125
* \param[in] result the result the branch index will be computed for
126
* \param[in] flag the flag corresponding to the specified result
127
* \param[in] threshold the threshold used to compute the branch index
128
* \param[out] branch_index the destination for the computed branch index
129
*/
130
inline
void
131
computeBranchIndex
(
const
float
result,
132
const
unsigned
char
flag,
133
const
float
threshold,
134
unsigned
char
& branch_index)
const override
135
{
136
if
(flag == 0)
137
branch_index = (result > threshold) ? 1 : 0;
138
else
139
branch_index = 2;
140
}
141
};
142
143
}
// 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:97
pcl::BinaryTreeThresholdBasedBranchEstimator::~BinaryTreeThresholdBasedBranchEstimator
~BinaryTreeThresholdBasedBranchEstimator()
Destructor.
Definition
branch_estimator.h:80
pcl::BinaryTreeThresholdBasedBranchEstimator::getNumOfBranches
std::size_t getNumOfBranches() const override
Returns the number of branches the corresponding tree has.
Definition
branch_estimator.h:84
pcl::BinaryTreeThresholdBasedBranchEstimator::BinaryTreeThresholdBasedBranchEstimator
BinaryTreeThresholdBasedBranchEstimator()
Constructor.
Definition
branch_estimator.h:78
pcl::BranchEstimator
Interface for branch estimators.
Definition
branch_estimator.h:50
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()
Destructor.
Definition
branch_estimator.h:53
pcl::TernaryTreeMissingDataBranchEstimator::getNumOfBranches
std::size_t getNumOfBranches() const override
Returns the number of branches the corresponding tree has.
Definition
branch_estimator.h:118
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:131
pcl::TernaryTreeMissingDataBranchEstimator::~TernaryTreeMissingDataBranchEstimator
~TernaryTreeMissingDataBranchEstimator()
Destructor.
Definition
branch_estimator.h:114
pcl::TernaryTreeMissingDataBranchEstimator::TernaryTreeMissingDataBranchEstimator
TernaryTreeMissingDataBranchEstimator()
Constructor.
Definition
branch_estimator.h:112
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