intensity_to_color_points_processor.cc
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 
18 
19 #include "Eigen/Core"
22 #include "glog/logging.h"
23 
24 namespace cartographer {
25 namespace io {
26 
27 std::unique_ptr<IntensityToColorPointsProcessor>
29  common::LuaParameterDictionary* const dictionary,
30  PointsProcessor* const next) {
31  const string frame_id =
32  dictionary->HasKey("frame_id") ? dictionary->GetString("frame_id") : "";
33  const float min_intensity = dictionary->GetDouble("min_intensity");
34  const float max_intensity = dictionary->GetDouble("max_intensity");
35  return common::make_unique<IntensityToColorPointsProcessor>(
36  min_intensity, max_intensity, frame_id, next);
37 }
38 
40  const float min_intensity, const float max_intensity,
41  const string& frame_id, PointsProcessor* const next)
42  : min_intensity_(min_intensity),
43  max_intensity_(max_intensity),
44  frame_id_(frame_id),
45  next_(next) {}
46 
48  std::unique_ptr<PointsBatch> batch) {
49  if (!batch->intensities.empty() &&
50  (frame_id_.empty() || batch->frame_id == frame_id_)) {
51  batch->colors.clear();
52  for (const float intensity : batch->intensities) {
53  const uint8_t gray =
55  (intensity - min_intensity_) / (max_intensity_ - min_intensity_),
56  0.f, 1.f) *
57  255;
58  batch->colors.push_back(Color{{gray, gray, gray}});
59  }
60  }
61  next_->Process(std::move(batch));
62 }
63 
65  return next_->Flush();
66 }
67 
68 } // namespace io
69 } // namespace cartographer
virtual void Process(std::unique_ptr< PointsBatch > points_batch)=0
IntensityToColorPointsProcessor(float min_intensity, float max_intensity, const string &frame_id, PointsProcessor *next)
std::array< uint8_t, 3 > Color
Definition: points_batch.h:31
void Process(std::unique_ptr< PointsBatch > batch) override
virtual FlushResult Flush()=0
T Clamp(const T value, const T min, const T max)
Definition: math.h:32
static std::unique_ptr< IntensityToColorPointsProcessor > FromDictionary(common::LuaParameterDictionary *dictionary, PointsProcessor *next)


cartographer
Author(s):
autogenerated on Wed Jun 5 2019 21:57:58