CARLA
 
载入中...
搜索中...
未找到
ColorConverter.h
浏览该文件的文档.
1// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
11
12namespace carla {
13namespace image {
14
16 public:
17
19 template <typename DstPixelT>
20 void operator()(const boost::gil::gray32fc_pixel_t &src, DstPixelT &dst) const {
21 using namespace boost::gil;
22 const float value = 1.0f + std::log(src[0u]) / 5.70378f;
23 const float clamped = std::max(std::min(value, 1.0f), 0.005f);
24 color_convert(gray32fc_pixel_t{clamped}, dst);
25 }
26 };
27
28 struct Depth {
29 template <typename SrcPixelT, typename DstPixelT>
30 void operator()(const SrcPixelT &src, DstPixelT &dst) const {
31 using namespace boost::gil;
32 static_assert(
33 sizeof(typename color_space_type<SrcPixelT>::type) == sizeof(uint8_t),
34 "Invalid pixel type.");
35 const float depth =
36 get_color(src, red_t()) +
37 (get_color(src, green_t()) * 256) +
38 (get_color(src, blue_t()) * 256 * 256);
39 const float normalized = depth / static_cast<float>(256 * 256 * 256 - 1);
40 color_convert(gray32fc_pixel_t{normalized}, dst);
41 }
42 };
43
45
47 template <typename SrcPixelT, typename DstPixelT>
48 void operator()(const SrcPixelT &src, DstPixelT &dst) const {
49 using namespace boost::gil;
50 static_assert(
51 sizeof(typename color_space_type<SrcPixelT>::type) == sizeof(uint8_t),
52 "Invalid pixel type.");
53 const auto color = image::CityScapesPalette::GetColor(get_color(src, red_t()));
54 color_convert(rgb8c_pixel_t{color[0u], color[1u], color[2u]}, dst);
55 }
56 };
57 };
58
59} // namespace image
60} // namespace carla
static constexpr auto GetColor(uint8_t tag)
Return an RGB uint8_t array.
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133
void operator()(const SrcPixelT &src, DstPixelT &dst) const
void operator()(const SrcPixelT &src, DstPixelT &dst) const
void operator()(const boost::gil::gray32fc_pixel_t &src, DstPixelT &dst) const