depth_map_preprocessing
PointCloudConversion.hpp
Go to the documentation of this file.
1 #ifndef _DEPTH_MAP_PREPROCESSING_POINTCLOUD_CONVERSION_HPP_
2 #define _DEPTH_MAP_PREPROCESSING_POINTCLOUD_CONVERSION_HPP_
3 
4 #include <base-logging/Logging.hpp>
5 #include <base/samples/DepthMap.hpp>
6 #include <list>
7 #include <vector>
8 #include "Config.hpp"
9 
11 {
12 
14 {
15 public:
16  typedef std::vector<Eigen::Affine3d, Eigen::aligned_allocator<Eigen::Affine3d>> TransformationVector;
17 
26  template<class T>
27  static bool convertToPointCloud(const base::samples::DepthMap &depth_map_sample,
28  const TransformationVector& depth_map_transforms,
29  MotionCompensation motion_compensation, std::vector<T>& pointcloud);
30 
31 
39  static void computeLocalTransfromations(const TransformationVector& transformations, TransformationVector& laserLinesInLatestLine);
40 };
41 
42 
43 
44 template<class T>
45 bool PointCloudConversion::convertToPointCloud(const base::samples::DepthMap& depth_map_sample,
46  const TransformationVector& depth_map_transforms,
47  MotionCompensation motion_compensation, std::vector< T >& pointcloud)
48 {
49  TransformationVector laserLinesToLatestLine;
50  computeLocalTransfromations(depth_map_transforms, laserLinesToLatestLine);
51 
52  if((motion_compensation == HorizontalInterpolation || motion_compensation == VerticalInterpolation) && laserLinesToLatestLine.size() == 2)
53  {
54  if(depth_map_sample.timestamps.front() <= depth_map_sample.timestamps.back())
55  depth_map_sample.convertDepthMapToPointCloud(pointcloud, laserLinesToLatestLine.front(), laserLinesToLatestLine.back(),
56  true, true, motion_compensation == HorizontalInterpolation ? false : true);
57  else
58  depth_map_sample.convertDepthMapToPointCloud(pointcloud, laserLinesToLatestLine.back(), laserLinesToLatestLine.front(),
59  true, true, motion_compensation == HorizontalInterpolation ? false : true);
60  return true;
61  }
62  else if((motion_compensation == Horizontal && laserLinesToLatestLine.size() == depth_map_sample.horizontal_size) ||
63  (motion_compensation == Vertical && laserLinesToLatestLine.size() == depth_map_sample.vertical_size))
64  {
65  if(depth_map_sample.timestamps.front() <= depth_map_sample.timestamps.back())
66  depth_map_sample.convertDepthMapToPointCloud(pointcloud, laserLinesToLatestLine,
67  true, true, motion_compensation == Horizontal ? false : true);
68  else
69  {
70  TransformationVector laserLinesToLatestLine_reverse(laserLinesToLatestLine.size());
71  for(unsigned i = 1; i <= laserLinesToLatestLine.size(); i++)
72  laserLinesToLatestLine_reverse[laserLinesToLatestLine.size()-i] = laserLinesToLatestLine[i-1];
73  depth_map_sample.convertDepthMapToPointCloud(pointcloud, laserLinesToLatestLine_reverse,
74  true, true, motion_compensation == Horizontal ? false : true);
75  }
76  return true;
77  }
78  return false;
79 }
80 
81 }
82 
83 #endif
MotionCompensation
Definition: Config.hpp:22
static bool convertToPointCloud(const base::samples::DepthMap &depth_map_sample, const TransformationVector &depth_map_transforms, MotionCompensation motion_compensation, std::vector< T > &pointcloud)
Definition: PointCloudConversion.hpp:45
Definition: Config.hpp:4
Definition: PointCloudConversion.hpp:13
static void computeLocalTransfromations(const TransformationVector &transformations, TransformationVector &laserLinesInLatestLine)
Definition: PointCloudConversion.cpp:5
Definition: Config.hpp:26
Definition: Config.hpp:28
std::vector< Eigen::Affine3d, Eigen::aligned_allocator< Eigen::Affine3d > > TransformationVector
Definition: PointCloudConversion.hpp:16