logger.h
Go to the documentation of this file.
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 #ifndef _OPENGR_UTILS_LOGGER_H
48 #define _OPENGR_UTILS_LOGGER_H
49 
50 #include <iostream>
51 
52 namespace gr{
53 namespace Utils{
54 
55 enum LogLevel {
56  NoLog = 0,
58  Verbose = 2
59 };
60 
61 
62 class Logger {
63 private:
64  LogLevel logLevel_;
65 
66 
67 public:
68  inline Logger(LogLevel loglevel = Verbose) : logLevel_(loglevel) {}
69 
70  inline void setLogLevel(LogLevel loglevel) { logLevel_ = loglevel; }
71  inline LogLevel logLevel() const { return logLevel_; }
72 
73  template <LogLevel level, typename...Args>
74  inline void Log(const Args&...args) const{
75  switch(logLevel_) {
76  case NoLog:
77  LOG<NoLog, level>(args...);
78  break;
79  case ErrorReport:
80  LOG<ErrorReport, level>(args...);
81  break;
82  case Verbose:
83  LOG<Verbose, level>(args...);
84  break;
85  default:
86  break;
87  }
88  }
89 
90 protected:
91  static inline void print_err_impl(){
92  std::cerr << std::endl;
93  }
94 
95  template<typename First, typename...Rest>
96  static inline void print_err_impl(const First& param1, const Rest&...param){
97  std::cerr << param1;
98  print_err_impl(param...);
99  }
100  static inline void print_msg_impl(){
101  std::cout << std::endl;
102  }
103 
104  template<typename First, typename...Rest>
105  static inline void print_msg_impl(const First& param1, const Rest&...param){
106  std::cout << param1;
107  print_msg_impl(param...);
108  }
109 
110  template<LogLevel msgLevel, LogLevel appLevel, typename...Args>
111  static inline void LOG( const Args&...args) {
112  if(msgLevel >= appLevel){
113  if (msgLevel == ErrorReport)
114  print_err_impl(args...);
115  else
116  print_msg_impl(args...);
117  }
118  }
119 }; // class Logger
120 } // namespace Utils
121 } // namespace gr
122 
123 
124 #endif // LOGGER_H
static void print_msg_impl()
Definition: logger.h:100
Definition: logger.h:56
static void print_err_impl(const First &param1, const Rest &...param)
Definition: logger.h:96
Definition: logger.h:57
static void print_err_impl()
Definition: logger.h:91
CongruentSetExplorationBase< Traits, PointType, TransformVisitor, PairFilteringFunctor, OptExts... >::Scalar ComputeTransformation(const InputRange1 &P, const InputRange2 &Q, Eigen::Ref< typename CongruentSetExplorationBase< Traits, PointType, TransformVisitor, PairFilteringFunctor, OptExts... >::MatrixType > transformation, const Sampler< PointType > &sampler, TransformVisitor &v)
Definition: congruentSetExplorationBase.hpp:61
void get(int queryId, int nElPerDim, int, typename NeighborhoodType< 3 >::ptr first, typename NeighborhoodType< 3 >::ptr)
Definition: utils.h:279
LogLevel
Definition: logger.h:55
void setLogLevel(LogLevel loglevel)
Definition: logger.h:70
void Log(const Args &...args) const
Definition: logger.h:74
Definition: logger.h:62
Logger(LogLevel loglevel=Verbose)
Definition: logger.h:68
static void print_msg_impl(const First &param1, const Rest &...param)
Definition: logger.h:105
Definition: logger.h:58
LogLevel logLevel() const
Definition: logger.h:71
static void LOG(const Args &...args)
Definition: logger.h:111