Point Cloud Library (PCL)  1.9.1
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 #ifndef PCL_ML_BRANCH_ESTIMATOR_H_
39 #define PCL_ML_BRANCH_ESTIMATOR_H_
40 
41 #include <pcl/common/common.h>
42 #include <pcl/ml/stats_estimator.h>
43 
44 #include <istream>
45 #include <ostream>
46 
47 namespace pcl
48 {
49 
50  /** \brief Interface for branch estimators. */
51  class PCL_EXPORTS BranchEstimator
52  {
53  public:
54  /** \brief Destructor. */
55  virtual ~BranchEstimator () {}
56 
57  /** \brief Returns the number of branches the corresponding tree has. */
58  virtual size_t
59  getNumOfBranches () const = 0;
60 
61  /** \brief Computes the branch index for the specified result.
62  * \param[in] result The result the branch index will be computed for.
63  * \param[in] flag The flag corresponding to the specified result.
64  * \param[in] threshold The threshold used to compute the branch index.
65  * \param[out] branch_index The destination for the computed branch index.
66  */
67  virtual void
68  computeBranchIndex(
69  const float result,
70  const unsigned char flag,
71  const float threshold,
72  unsigned char & branch_index) const = 0;
73  };
74 
75  /** \brief Branch estimator for binary trees where the branch is computed only from the threshold. */
77  : public BranchEstimator
78  {
79  public:
80  /** \brief Constructor. */
82  /** \brief Destructor. */
84 
85  /** \brief Returns the number of branches the corresponding tree has. */
86  inline size_t
88  {
89  return 2;
90  }
91 
92  /** \brief Computes the branch index for the specified result.
93  * \param[in] result The result the branch index will be computed for.
94  * \param[in] flag The flag corresponding to the specified result.
95  * \param[in] threshold The threshold used to compute the branch index.
96  * \param[out] branch_index The destination for the computed branch index.
97  */
98  inline void
100  const float result,
101  const unsigned char flag,
102  const float threshold,
103  unsigned char & branch_index) const
104  {
105  (void)flag;
106  branch_index = (result > threshold) ? 1 : 0;
107  }
108  };
109 
110  /** \brief Branch estimator for ternary trees where one branch is used for missing data (indicated by flag != 0). */
112  : public BranchEstimator
113  {
114  public:
115  /** \brief Constructor. */
117  /** \brief Destructor. */
119 
120  /** \brief Returns the number of branches the corresponding tree has. */
121  inline size_t
123  {
124  return 3;
125  }
126 
127  /** \brief Computes the branch index for the specified result.
128  * \param[in] result The result the branch index will be computed for.
129  * \param[in] flag The flag corresponding to the specified result.
130  * \param[in] threshold The threshold used to compute the branch index.
131  * \param[out] branch_index The destination for the computed branch index.
132  */
133  inline void
135  const float result,
136  const unsigned char flag,
137  const float threshold,
138  unsigned char & branch_index) const
139  {
140  if (flag == 0)
141  branch_index = (result > threshold) ? 1 : 0;
142  else
143  branch_index = 2;
144  }
145  };
146 
147 }
148 
149 #endif
size_t getNumOfBranches() const
Returns the number of branches the corresponding tree has.
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
Branch estimator for binary trees where the branch is computed only from the threshold.
Define standard C methods and C++ classes that are common to all methods.
void computeBranchIndex(const float result, const unsigned char flag, const float threshold, unsigned char &branch_index) const
Computes the branch index for the specified result.
Branch estimator for ternary trees where one branch is used for missing data (indicated by flag != 0)...
virtual ~BinaryTreeThresholdBasedBranchEstimator()
Destructor.
virtual ~BranchEstimator()
Destructor.
size_t getNumOfBranches() const
Returns the number of branches the corresponding tree has.
virtual ~TernaryTreeMissingDataBranchEstimator()
Destructor.
Interface for branch estimators.
void computeBranchIndex(const float result, const unsigned char flag, const float threshold, unsigned char &branch_index) const
Computes the branch index for the specified result.