Point Cloud Library (PCL) 1.12.0
Loading...
Searching...
No Matches
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
47namespace pcl {
48
49/** Interface for branch estimators. */
50class PCL_EXPORTS BranchEstimator {
51public:
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
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. */
76public:
77 /** Constructor. */
79 /** Destructor. */
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
98 const unsigned char flag,
99 const float threshold,
100 unsigned char& branch_index) const override
101 {
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). */
110public:
111 /** Constructor. */
113 /** Destructor. */
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
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
Branch estimator for binary trees where the branch is computed only from the threshold.
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.
std::size_t getNumOfBranches() const override
Returns the number of branches the corresponding tree has.
Interface for branch estimators.
virtual std::size_t getNumOfBranches() const =0
Returns the number of branches the corresponding tree has.
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.
virtual ~BranchEstimator()
Destructor.
Iterator class for point clouds with or without given indices.
Branch estimator for ternary trees where one branch is used for missing data (indicated by flag !...
std::size_t getNumOfBranches() const override
Returns the number of branches the corresponding tree has.
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.
Define standard C methods and C++ classes that are common to all methods.
void ignore(const T &...)
Utility function to eliminate unused variable warnings.
Definition utils.h:62