OCLSLAM  0.1.0
 Hosted by GitHub
helper_funcs.hpp
Go to the documentation of this file.
1 
29 #ifndef OCLSLAM_HELPERFUNCS_HPP
30 #define OCLSLAM_HELPERFUNCS_HPP
31 
32 #include <cassert>
33 #include <algorithm>
34 #include <functional>
35 #include <RBC/data_types.hpp>
36 
37 #if defined(__APPLE__) || defined(__MACOSX)
38 #include <OpenCL/cl.hpp>
39 #else
40 #include <CL/cl.hpp>
41 #endif
42 
43 
47 namespace oclslam
48 {
49 
51  bool setProfilingFlag (int argc, char **argv);
52 
53 
59  template <typename T>
60  uint64_t nextPow2 (T num)
61  {
62  assert (num >= 0);
63 
64  uint64_t pow;
65  for (pow = 1; pow < (uint64_t) num; pow <<= 1) ;
66 
67  return pow;
68  }
69 
70 
79  template <typename T>
80  void printBuffer (const char *title, T *ptr, uint32_t width, uint32_t height)
81  {
82  std::cout << title << std::endl;
83 
84  for (int row = 0; row < height; ++row)
85  {
86  for (int col = 0; col < width; ++col)
87  {
88  std::cout << std::setw (3 * sizeof (T)) << +ptr[row * width + col] << " ";
89  }
90  std::cout << std::endl;
91  }
92 
93  std::cout << std::endl;
94  }
95 
96 
106  template <typename T>
107  void printBufferF (const char *title, T *ptr, uint32_t width, uint32_t height, uint32_t prec)
108  {
109  std::ios::fmtflags f (std::cout.flags ());
110  std::cout << title << std::endl;
111  std::cout << std::fixed << std::setprecision (prec);
112 
113  for (int row = 0; row < height; ++row)
114  {
115  for (int col = 0; col < width; ++col)
116  {
117  std::cout << std::setw (5 + prec) << ptr[row * width + col] << " ";
118  }
119  std::cout << std::endl;
120  }
121 
122  std::cout << std::endl;
123  std::cout.flags (f);
124  }
125 
126 
136  template <typename T>
137  void cpuSplitPC8D (T *pc8d, T *pc3d, cl_uchar *rgb, uint32_t n)
138  {
139  for (uint k = 0; k < n; ++k)
140  {
141  cl_float *point = pc8d + (k << 3);
142 
143  for (uint j = 0; j < 3; ++j)
144  {
145  pc3d[3 * k + j] = point[j] * 0.001;
146  rgb[3 * k + j] = (cl_uchar) (point[4 + j] * 255);
147  }
148  }
149  }
150 
151 }
152 
153 #endif // OCLSLAM_HELPERFUNCS_HPP
void printBuffer(const char *title, T *ptr, uint32_t width, uint32_t height)
Prints an array of an integer type to standard output.
Definition: helper_funcs.hpp:80
const int width
Definition: glut_viewer.cpp:53
uint64_t nextPow2(T num)
Returns the first power of 2 greater than or equal to the input.
Definition: helper_funcs.hpp:60
bool setProfilingFlag(int argc, char **argv)
Checks the command line arguments for the profiling flag, --profiling.
Definition: helper_funcs.cpp:66
Offers functions that are serial CPU implementations of the relevant algorithms in the OCLSLAM pipeli...
Definition: helper_funcs.hpp:47
void cpuSplitPC8D(T *pc8d, T *pc3d, cl_uchar *rgb, uint32_t n)
Splits an 8-D point cloud into 3-D coordinates (in meters) and 8-bit RGB values.
Definition: helper_funcs.hpp:137
const int height
Definition: glut_viewer.cpp:54
void printBufferF(const char *title, T *ptr, uint32_t width, uint32_t height, uint32_t prec)
Prints an array of floating-point type to standard output.
Definition: helper_funcs.hpp:107