Point Cloud Library (PCL)  1.14.1-dev
ransac.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2009, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $Id$
35  *
36  */
37 
38 #pragma once
39 
40 #include <pcl/cuda/sample_consensus/sac.h>
41 #include <pcl/cuda/sample_consensus/sac_model.h>
42 
43 namespace pcl
44 {
45  namespace cuda
46  {
47  /** \brief @b RandomSampleConsensus represents an implementation of the
48  * RANSAC (RAndom SAmple Consensus) algorithm, as described in: "Random
49  * Sample Consensus: A Paradigm for Model Fitting with Applications to Image
50  * Analysis and Automated Cartography", Martin A. Fischler and Robert C. Bolles,
51  * Comm. Of the ACM 24: 381–395, June 1981.
52  * \author Radu Bogdan Rusu
53  */
54  template <template <typename> class Storage>
55  class RandomSampleConsensus : public SampleConsensus<Storage>
56  {
66 
67  using SampleConsensusModelPtr = typename SampleConsensusModel<Storage>::Ptr;
68  using Coefficients = typename SampleConsensusModel<Storage>::Coefficients;
69  using Indices = typename SampleConsensusModel<Storage>::Indices;
70  using Hypotheses = typename SampleConsensusModel<Storage>::Hypotheses;
71 
72  public:
73  /** \brief RANSAC (RAndom SAmple Consensus) main constructor
74  * \param model a Sample Consensus model
75  */
76  RandomSampleConsensus (const SampleConsensusModelPtr &model) :
77  SampleConsensus<Storage> (model)
78  {
79  // Maximum number of trials before we give up.
80  max_iterations_ = 10000;
81  }
82 
83  /** \brief RANSAC (RAndom SAmple Consensus) main constructor
84  * \param model a Sample Consensus model
85  * \param threshold distance to model threshold
86  */
87  RandomSampleConsensus (const SampleConsensusModelPtr &model, float threshold) :
88  SampleConsensus<Storage> (model, threshold)
89  {
90  // Maximum number of trials before we give up.
91  max_iterations_ = 10000;
92  }
93 
94  /** \brief Compute the actual model and find the inliers
95  * \param debug_verbosity_level enable/disable on-screen debug
96  * information and set the verbosity level
97  */
98  bool
99  computeModel (int debug_verbosity_level = 0);
100  };
101  } // namespace
102 } // namespace
RandomSampleConsensus represents an implementation of the RANSAC (RAndom SAmple Consensus) algorithm,...
Definition: ransac.h:56
RandomSampleConsensus(const SampleConsensusModelPtr &model)
RANSAC (RAndom SAmple Consensus) main constructor.
Definition: ransac.h:76
bool computeModel(int debug_verbosity_level=0)
Compute the actual model and find the inliers.
RandomSampleConsensus(const SampleConsensusModelPtr &model, float threshold)
RANSAC (RAndom SAmple Consensus) main constructor.
Definition: ransac.h:87
int max_iterations_
Maximum number of iterations before giving up.
Definition: sac.h:195
typename Storage< float4 >::type Hypotheses
Definition: sac_model.h:105
typename Storage< float >::type Coefficients
Definition: sac_model.h:101
typename Storage< int >::type Indices
Definition: sac_model.h:97
shared_ptr< SampleConsensusModel > Ptr
Definition: sac_model.h:94