xray_points_processor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016 The Cartographer Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CARTOGRAPHER_IO_XRAY_POINTS_PROCESSOR_H_
18 #define CARTOGRAPHER_IO_XRAY_POINTS_PROCESSOR_H_
19 
20 #include <map>
21 
22 #include "Eigen/Core"
27 #include "cartographer/mapping/proto/trajectory.pb.h"
30 
31 namespace cartographer {
32 namespace io {
33 
34 // Creates X-ray cuts through the points with pixels being 'voxel_size' big.
36  public:
37  constexpr static const char* kConfigurationFileActionName =
38  "write_xray_image";
39  XRayPointsProcessor(double voxel_size, const transform::Rigid3f& transform,
40  const std::vector<mapping::Floor>& floors,
41  const string& output_filename,
42  FileWriterFactory file_writer_factory,
43  PointsProcessor* next);
44 
45  static std::unique_ptr<XRayPointsProcessor> FromDictionary(
46  const mapping::proto::Trajectory& trajectory,
47  FileWriterFactory file_writer_factory,
49 
50  ~XRayPointsProcessor() override {}
51 
52  void Process(std::unique_ptr<PointsBatch> batch) override;
53  FlushResult Flush() override;
54 
55  Eigen::AlignedBox3i bounding_box() const { return bounding_box_; }
56 
57  private:
58  struct ColumnData {
59  double sum_r = 0.;
60  double sum_g = 0.;
61  double sum_b = 0.;
62  uint32_t count = 0;
63  };
64 
65  struct Aggregation {
67  std::map<std::pair<int, int>, ColumnData> column_data;
68  };
69 
70  void WriteVoxels(const Aggregation& aggregation,
71  FileWriter* const file_writer);
72  void Insert(const PointsBatch& batch, const transform::Rigid3f& transform,
73  Aggregation* aggregation);
74 
77 
78  // If empty, we do not separate into floors.
79  std::vector<mapping::Floor> floors_;
80 
81  const string output_filename_;
83 
84  // Only has one entry if we do not separate into floors.
85  std::vector<Aggregation> aggregations_;
86 
87  // Bounding box containing all cells with data in all 'aggregations_'.
88  Eigen::AlignedBox3i bounding_box_;
89 };
90 
91 } // namespace io
92 } // namespace cartographer
93 
94 #endif // CARTOGRAPHER_IO_XRAY_POINTS_PROCESSOR_H_
std::function< std::unique_ptr< FileWriter >(const string &filename)> FileWriterFactory
Definition: file_writer.h:63
std::map< std::pair< int, int >, ColumnData > column_data
void Insert(const PointsBatch &batch, const transform::Rigid3f &transform, Aggregation *aggregation)
static std::unique_ptr< XRayPointsProcessor > FromDictionary(const mapping::proto::Trajectory &trajectory, FileWriterFactory file_writer_factory, common::LuaParameterDictionary *dictionary, PointsProcessor *next)
std::vector< mapping::Floor > floors_
XRayPointsProcessor(double voxel_size, const transform::Rigid3f &transform, const std::vector< mapping::Floor > &floors, const string &output_filename, FileWriterFactory file_writer_factory, PointsProcessor *next)
std::vector< Aggregation > aggregations_
void WriteVoxels(const Aggregation &aggregation, FileWriter *const file_writer)
static constexpr const char * kConfigurationFileActionName
Eigen::AlignedBox3i bounding_box() const
void Process(std::unique_ptr< PointsBatch > batch) override


cartographer
Author(s):
autogenerated on Mon Jun 10 2019 12:51:39