iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CorrespondenceRejectionRANSAC.H
Go to the documentation of this file.
1 /*! @file
2  @author Shane Grant
3  @copyright GNU Public License (GPL v3)
4  @section License
5  @verbatim
6  // ////////////////////////////////////////////////////////////////////////
7  // The iLab Neuromorphic Robotics Toolkit (NRT) //
8  // Copyright 2010-2012 by the University of Southern California (USC) //
9  // and the iLab at USC. //
10  // //
11  // iLab - University of Southern California //
12  // Hedco Neurociences Building, Room HNB-10 //
13  // Los Angeles, Ca 90089-2520 - USA //
14  // //
15  // See http://ilab.usc.edu for information about this project. //
16  // ////////////////////////////////////////////////////////////////////////
17  // This file is part of The iLab Neuromorphic Robotics Toolkit. //
18  // //
19  // The iLab Neuromorphic Robotics Toolkit is free software: you can //
20  // redistribute it and/or modify it under the terms of the GNU General //
21  // Public License as published by the Free Software Foundation, either //
22  // version 3 of the License, or (at your option) any later version. //
23  // //
24  // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
25  // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
26  // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
27  // PURPOSE. See the GNU General Public License for more details. //
28  // //
29  // You should have received a copy of the GNU General Public License //
30  // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
31  // <http://www.gnu.org/licenses/>. //
32  // ////////////////////////////////////////////////////////////////////////
33  @endverbatim */
34 
35 #ifdef NRT_HAVE_CLOUD
36 #ifndef NRT_POINTCLOUD2_REGISTRATION_CORRESPONDENCE_REJECTION_CORRESPONDENCEREJECTIONRANSAC_H_
37 #define NRT_POINTCLOUD2_REGISTRATION_CORRESPONDENCE_REJECTION_CORRESPONDENCEREJECTIONRANSAC_H_
38 
41 
42 namespace nrt
43 {
44  //! Rejects correspondences based on some threshold distance
45  /*! The threshold distance will be applied to the score field of
46  the correspondences to determine whether they are within range. */
48  {
49  typedef PointCloud2::Matrix4 Matrix4;
50 
51  public:
52  //! Create with some distance threshold
53  /*! @param inlierThreshold The distance threshold for RANSAC to consider inliers, in meters
54  @param maxRANSACIterations Maximum number of iterations to run RANSAC
55  @param maxSampleIterations Maximum number of iterations to search for a suitable model sample
56  @param ransacOutlierFreeProbability Probability of having no outliers
57  @param seedRandom If true, use a new random seed, if false, use some default */
59  double inlierThreshold = std::numeric_limits<double>::max(),
60  size_t maxRANSACIterations = 1000,
61  size_t maxSampleIterations = 1000,
62  double ransacOutlierFreeProbability = 0.99,
63  bool seedRandom = false );
64 
65  //! Applies some criterion to an input set of correspondences to prune them
66  /*! @param source The pointcloud where source indices came from
67  @param target The pointcloud where target indices came from
68  @param correspondences The correspondences between source and target
69  @return The pruned set of correspondences */
70  Correspondences reject( PointCloud2 const source,
71  PointCloud2 const target,
72  Correspondences const correspondences );
73 
74  //! Returns the best transform selected by the previous run of reject()
75  Matrix4 getBestTransform() const;
76 
77  private:
78  RandomSampleConcensus itsRANSAC;
79  const double itsInlierThreshold;
80  const size_t itsMaxSampleIters;
81  const bool itsSeedRandom;
82  Matrix4 itsTransform;
83  };
84 } // namespace nrt
85 
86 #endif // NRT_POINTCLOUD2_REGISTRATION_CORRESPONDENCE_REJECTION_CORRESPONDENCEREJECTIONRANSAC_H_
87 #endif // NRT_HAVE_CLOUD