farm-ng-core
pixel_format.h
Go to the documentation of this file.
1 // Copyright (c) 2011, Hauke Strasdat
2 // Copyright (c) 2012, Steven Lovegrove
3 // Copyright (c) 2021, farm-ng, inc.
4 //
5 // Use of this source code is governed by an MIT-style
6 // license that can be found in the LICENSE file or at
7 // https://opensource.org/licenses/MIT.
8 
9 #pragma once
10 
12 
13 namespace sophus {
14 
15 struct PixelFormat {
16  template <class TPixel>
17  static auto fromTemplate() -> PixelFormat {
18  return PixelFormat{
19  .number_type =
20  std::is_floating_point_v<typename ImageTraits<TPixel>::ChannelT>
21  ? NumberType::floating_point
22  : NumberType::fixed_point,
23  .num_components = ImageTraits<TPixel>::kNumChannels,
24  .num_bytes_per_component =
25  sizeof(typename ImageTraits<TPixel>::ChannelT)};
26  }
27 
28  [[nodiscard]] inline auto numBytesPerPixel() const -> size_t {
30  }
31 
32  template <class TPixel>
33  [[nodiscard]] auto is() -> bool {
34  return fromTemplate<TPixel>() == *this;
35  }
36 
37  NumberType number_type;
38  uint8_t num_components;
40 };
41 
42 auto operator==(PixelFormat const& lhs, PixelFormat const& rhs) -> bool;
43 
44 /// Example:
45 /// PixelFormat::fromTemplate<float>() outputs: "1F32";
46 /// PixelFormat::fromTemplate<Eigen::Matrix<uint8_t,4,1>>() outputs:
47 /// "4U8";
48 auto operator<<(std::ostream& os, PixelFormat const& type) -> std::ostream&;
49 } // namespace sophus
sophus
Image MutImage, owning images types.
Definition: num_diff.h:20
image_types.h
sophus::PixelFormat::number_type
NumberType number_type
Definition: pixel_format.h:37
sophus::ImageTraits::ChannelT
TPixel ChannelT
Definition: image_types.h:121
sophus::ImageTraits
Number type.
Definition: image_types.h:118
sophus::PixelFormat::num_components
uint8_t num_components
Definition: pixel_format.h:38
sophus::PixelFormat::num_bytes_per_component
size_t num_bytes_per_component
Definition: pixel_format.h:39
sophus::PixelFormat::fromTemplate
static auto fromTemplate() -> PixelFormat
Definition: pixel_format.h:17
sophus::operator==
auto operator==(Region< TT > const &lhs, Region< TT > const &rhs) -> bool
Definition: region.h:367
sophus::PixelFormat::numBytesPerPixel
auto numBytesPerPixel() const -> size_t
Definition: pixel_format.h:28
sophus::operator<<
auto operator<<(std::ostream &os, ImageSize const &image_size) -> std::ostream &
Ostream operator.
Definition: image_size.cpp:46
sophus::PixelFormat::is
auto is() -> bool
Definition: pixel_format.h:33
core.event_service.type
type
Definition: event_service.py:547
sophus::PixelFormat
Definition: pixel_format.h:15