Go to the documentation of this file.
20 template <
class TPixel>
28 template <
class TPredicate = AnyImagePredicate>
34 template <
class TPixel>
38 static_assert(TPredicate::template isTypeValid<TPixel>());
41 template <
class TPixel>
42 [[nodiscard]]
auto has() const noexcept ->
bool {
43 PixelFormat expected_type = PixelFormat::fromTemplate<TPixel>();
50 [[nodiscard]]
auto rawRowPtr(
int v)
const -> uint8_t
const* {
54 [[nodiscard]]
auto rawPtr() const -> uint8_t const* {
return ptr_; }
62 [[nodiscard]]
auto area() const ->
size_t {
return layout().area(); }
63 [[nodiscard]]
auto width() const ->
int {
return layout().width(); }
64 [[nodiscard]]
auto height() const ->
int {
return layout().height(); }
66 return layout().pitchBytes();
71 [[nodiscard]]
auto isEmpty() const ->
bool {
72 return this->
rawPtr() ==
nullptr;
90 const size_t row_offset = uv.x() * this->
pixelFormat().numBytesPerPixel();
98 template <
class TPixel>
100 if (!this->has<TPixel>()) {
101 PixelFormat expected_type = PixelFormat::fromTemplate<TPixel>();
104 "expected type: {}\n"
111 this->
layout_,
reinterpret_cast<TPixel const*
>(
ptr_));
116 this->
ptr_ =
nullptr;
142 ptr_(reinterpret_cast<uint8_t const*>(ptr)) {
#define SOPHUS_PANIC(...)
Definition: common.h:50
#define SOPHUS_ASSERT(...)
Definition: common.h:40
uint8_t const * ptr_
Definition: dyn_image_view.h:148
auto pitchBytes() const -> size_t
Definition: layout.h:57
auto layout() const -> ImageLayout const &
Definition: dyn_image_view.h:56
Layout of the image: width, height and pitch in bytes.
Definition: layout.h:23
Image MutImage, owning images types.
Definition: num_diff.h:20
auto pixelFormat() const -> PixelFormat
Definition: dyn_image_view.h:75
auto imageSize() const -> ImageSize const &
Definition: dyn_image_view.h:58
A view of an (immutable) image, which does not own the data.
Definition: image_view.h:55
auto height() const -> int
Definition: dyn_image_view.h:64
auto isEmpty() const -> bool
Definition: dyn_image_view.h:71
void setViewToEmpty()
Definition: dyn_image_view.h:114
ImageLayout layout_
Definition: dyn_image_view.h:146
auto numChannels() const -> int
Definition: dyn_image_view.h:78
auto rawRowPtr(int v) const -> uint8_t const *
Returns v-th row pointer.
Definition: dyn_image_view.h:50
auto width() const -> int
Definition: dyn_image_view.h:63
PixelFormat pixel_format_
Definition: dyn_image_view.h:147
auto pitchBytes() const -> size_t
Definition: dyn_image_view.h:65
#define SOPHUS_ASSERT_LE(...)
Definition: common.h:44
auto has() const noexcept -> bool
Definition: dyn_image_view.h:42
static constexpr auto isTypeValid() -> bool
Definition: dyn_image_view.h:21
DynImageView(ImageView< TPixel > const &image)
Create type-erased image view from ImageView.
Definition: dyn_image_view.h:35
auto sizeBytes() const -> size_t
Definition: dyn_image_view.h:68
auto subview(Eigen::Vector2i uv, sophus::ImageSize size) const -> DynImageView
Returns subview with shared ownership semantics of whole image.
Definition: dyn_image_view.h:83
static DynImageView unsafeWrapAndPromiseProperAlignment(ImageLayout const &layout, PixelFormat const &pixel_format, void const *ptr)
Definition: dyn_image_view.h:126
DynImageView(ImageLayout const &layout, PixelFormat const &pixel_format, void const *ptr)
Definition: dyn_image_view.h:136
Definition: dyn_image_view.h:19
auto rawPtr() const -> uint8_t const *
Definition: dyn_image_view.h:54
auto imageView() const noexcept -> ImageView< TPixel >
Returns typed image.
Definition: dyn_image_view.h:99
auto imageSize() const -> sophus::ImageSize const &
Definition: layout.h:51
Image size, hence its width and height.
Definition: image_size.h:21
auto area() const -> size_t
Definition: dyn_image_view.h:62
Definition: dyn_image_view.h:29
static constexpr auto isFormatValid(PixelFormat) -> bool
Definition: dyn_image_view.h:25