UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
space.hpp
1
45#ifndef UFO_VISION_COLOR_SPACE_HPP
46#define UFO_VISION_COLOR_SPACE_HPP
47
48// STL
49#include <format>
50#include <ostream>
51#include <string_view>
52#include <utility>
53
54namespace ufo
55{
71enum class ColorSpace { NATIVE, Rgb, Oklab, Oklab2, Oklch };
72
78[[nodiscard]] constexpr std::string_view toString(ColorSpace cs) noexcept
79{
80 using namespace std::literals;
81 switch (cs) {
82 case ColorSpace::NATIVE: return "NATIVE"sv;
83 case ColorSpace::Rgb: return "Rgb"sv;
84 case ColorSpace::Oklab: return "OKLab"sv;
85 case ColorSpace::Oklab2: return "OKLab2"sv;
86 case ColorSpace::Oklch: return "OKLch"sv;
87 }
88 std::unreachable();
89}
90
94inline std::ostream& operator<<(std::ostream& out, ColorSpace cs)
95{
96 return out << toString(cs);
97}
98
102} // namespace ufo
103
110template <>
111struct std::formatter<ufo::ColorSpace> : std::formatter<std::string_view> {
112 auto format(ufo::ColorSpace cs, std::format_context& ctx) const
113 {
114 return std::formatter<std::string_view>::format(ufo::toString(cs), ctx);
115 }
116};
117
118#endif // UFO_VISION_COLOR_SPACE_HPP
ColorSpace
Selects the working color space for color operations.
Definition space.hpp:71
All vision-related classes and functions.
Definition cloud.hpp:49
constexpr std::string_view toString(ScalarType type) noexcept
Returns a human-readable string for a ScalarType value.
Gamma-encoded sRGB color.
Definition rgb.hpp:75