Point Cloud Library (PCL)  1.7.1
hv_papazov.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 #ifndef PCL_RECOGNITION_HV_PAPAZOV_H_
38 #define PCL_RECOGNITION_HV_PAPAZOV_H_
39 
40 #include <pcl/recognition/boost.h>
41 #include <pcl/pcl_macros.h>
42 #include <pcl/common/common.h>
43 #include <pcl/recognition/hv/hypotheses_verification.h>
44 #include <boost/graph/adjacency_list.hpp>
45 
46 namespace pcl
47 {
48 
49  /** \brief A hypothesis verification method proposed in
50  * "An Efficient RANSAC for 3D Object Recognition in Noisy and Occluded Scenes", C. Papazov and D. Burschka, ACCV 2010
51  * \author Aitor Aldoma, Federico Tombari
52  */
53 
54  template<typename ModelT, typename SceneT>
55  class PCL_EXPORTS PapazovHV : public HypothesisVerification<ModelT, SceneT>
56  {
64 
65  float conflict_threshold_size_;
66  float penalty_threshold_;
67  float support_threshold_;
68 
69  class RecognitionModel
70  {
71  public:
72  std::vector<int> explained_; //indices vector referencing explained_by_RM_
73  typename pcl::PointCloud<ModelT>::Ptr cloud_;
74  typename pcl::PointCloud<ModelT>::Ptr complete_cloud_;
75  int bad_information_;
76  int id_;
77  };
78 
79  std::vector<int> explained_by_RM_; //represents the points of scene_cloud_ that are explained by the recognition models
80  std::vector< boost::shared_ptr<RecognitionModel> > recognition_models_;
81  std::vector< std::vector <boost::shared_ptr<RecognitionModel> > > points_explained_by_rm_; //if inner size > 1, conflict
82  std::map<int, boost::shared_ptr<RecognitionModel> > graph_id_model_map_;
83 
84  typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, boost::shared_ptr<RecognitionModel> > Graph;
85  Graph conflict_graph_;
86 
87  //builds the conflict_graph
88  void buildConflictGraph();
89  //non-maxima suppresion on the conflict graph
90  void nonMaximaSuppresion();
91  //create recognition models
92  void initialize();
93 
94  public:
95  PapazovHV() : HypothesisVerification<ModelT,SceneT>() {
96  support_threshold_ = 0.1f;
97  penalty_threshold_ = 0.1f;
98  conflict_threshold_size_ = 0.02f;
99  }
100 
101  void setConflictThreshold(float t) {
102  conflict_threshold_size_ = t;
103  }
104 
105  void setSupportThreshold(float t) {
106  support_threshold_ = t;
107  }
108 
109  void setPenaltyThreshold(float t) {
110  penalty_threshold_ = t;
111  }
112 
113  //build conflict graph
114  //non-maxima supression
115  void verify();
116  };
117 }
118 
119 #ifdef PCL_NO_PRECOMPILE
120 #include <pcl/recognition/impl/hv/hv_papazov.hpp>
121 #endif
122 
123 #endif /* PCL_RECOGNITION_HV_PAPAZOV_H_ */
A hypothesis verification method proposed in "An Efficient RANSAC for 3D Object Recognition in Noisy ...
Definition: hv_papazov.h:55
Abstract class for hypotheses verification methods.
void setPenaltyThreshold(float t)
Definition: hv_papazov.h:109
void setConflictThreshold(float t)
Definition: hv_papazov.h:101
boost::shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:428
void setSupportThreshold(float t)
Definition: hv_papazov.h:105