Super4PCS Library  V1.1.2(719f5c0)
bruteForceFunctor.h
1 // Copyright 2014 Nicolas Mellado
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // -------------------------------------------------------------------------- //
16 //
17 // Authors: Nicolas Mellado
18 //
19 // An implementation of the Super 4-points Congruent Sets (Super 4PCS)
20 // algorithm presented in:
21 //
22 // Super 4PCS: Fast Global Pointcloud Registration via Smart Indexing
23 // Nicolas Mellado, Dror Aiger, Niloy J. Mitra
24 // Symposium on Geometry Processing 2014.
25 //
26 // Data acquisition in large-scale scenes regularly involves accumulating
27 // information across multiple scans. A common approach is to locally align scan
28 // pairs using Iterative Closest Point (ICP) algorithm (or its variants), but
29 // requires static scenes and small motion between scan pairs. This prevents
30 // accumulating data across multiple scan sessions and/or different acquisition
31 // modalities (e.g., stereo, depth scans). Alternatively, one can use a global
32 // registration algorithm allowing scans to be in arbitrary initial poses. The
33 // state-of-the-art global registration algorithm, 4PCS, however has a quadratic
34 // time complexity in the number of data points. This vastly limits its
35 // applicability to acquisition of large environments. We present Super 4PCS for
36 // global pointcloud registration that is optimal, i.e., runs in linear time (in
37 // the number of data points) and is also output sensitive in the complexity of
38 // the alignment problem based on the (unknown) overlap across scan pairs.
39 // Technically, we map the algorithm as an ‘instance problem’ and solve it
40 // efficiently using a smart indexing data organization. The algorithm is
41 // simple, memory-efficient, and fast. We demonstrate that Super 4PCS results in
42 // significant speedup over alternative approaches and allows unstructured
43 // efficient acquisition of scenes at scales previously not possible. Complete
44 // source code and datasets are available for research use at
45 // http://geometry.cs.ucl.ac.uk/projects/2014/super4PCS/.
46 
47 
48 #ifndef _SUPER4PCS_ACCELERATORS_BRUTE_FORCE_FUNCTOR_H_
49 #define _SUPER4PCS_ACCELERATORS_BRUTE_FORCE_FUNCTOR_H_
50 
51 #include "super4pcs/accelerators/pairExtraction/intersectionNode.h"
52 #include <list>
53 #include <iostream>
54 
55 namespace GlobalRegistration{
56 namespace Accelerators{
57 namespace PairExtraction{
58 
59 struct DummyPrimitive {};
60 
62 
67 template <class _DummyPrimitive, class _Point, int _dim, typename _Scalar>
69  typedef _Point Point;
70  typedef _Scalar Scalar;
71  enum { dim = _dim };
72 
73  template <class PrimitiveContainer,
74  class PointContainer,
75  class ProcessingFunctor>
76  inline
77  void
78  process(
79  const PrimitiveContainer & M,
80  const PointContainer & Q,
81  Scalar &epsilon,
82  unsigned int minNodeSize,
83  ProcessingFunctor& functor
84  );
85 
86 };
87 
88 
92 template <class DummyPrimitive, class Point, int dim, typename Scalar>
93 template <class PrimitiveContainer,
94  class PointContainer,
95  class ProcessingFunctor>
96 void
98  const PrimitiveContainer & M,
99  const PointContainer & Q,
100  Scalar &epsilon,
101  unsigned int /*minNodeSize*/,
102  ProcessingFunctor& functor
103  )
104 {
105 
106  const unsigned int sizeM = M.size();
107  const unsigned int sizeQ = Q.size();
108  for (unsigned int j = 0; j != sizeQ; ++j){
109  functor.beginPrimitiveCollect(j);
110  for (unsigned int i = 0; i != sizeM; ++i){
111  if( M[i].intersectPoint(Q[j], epsilon ))
112  functor.process(i,j);
113  }
114  functor.endPrimitiveCollect(j);
115  }
116 }
117 
118 } // namespace PairExtraction
119 } // namespace Accelerators
120 } // namespace Super4PCS
121 
122 #endif // _BRUTE_FORCE_FUNCTOR_H_
123 
Definition: bbox.h:54
Extract pairs of points using brute force approach.
Definition: bruteForceFunctor.h:68
void process(const PrimitiveContainer &M, const PointContainer &Q, Scalar &epsilon, unsigned int minNodeSize, ProcessingFunctor &functor)
< Process the extracted pairs
Definition: bruteForceFunctor.h:97