Go to the documentation of this file.
17 template <
class TPredicate,
class TAllocator>
21 class TPredicate = AnyImagePredicate,
22 class TAllocator = Eigen::aligned_allocator<uint8_t>>
41 template <
class TPixel>
48 static_assert(TPredicate::template isTypeValid<TPixel>());
55 if (!TPredicate::isFormatValid(pixel_format)) {
65 if (!TPredicate::isFormatValid(pixel_format)) {
93 MutDynImage image(image_view.imageSize(), image_view.pixelFormat());
99 template <
class TPixel>
100 [[nodiscard]]
auto has() const noexcept ->
bool {
101 PixelFormat expected_type = PixelFormat::fromTemplate<TPixel>();
108 template <
class TPixel>
112 mut_image.layout_ = this->
layout_;
114 mut_image.ptr_ = (TPixel*)mut_image.
unique_.get();
121 template <
class TPredicate2,
class TAllocator2T>
135 size, size.
width * pixel_format.numBytesPerPixel()),
138 TPredicate::isFormatValid(pixel_format),
"Internal logic error");
144 TPredicate::isFormatValid(pixel_format),
"Internal logic error");
static Expected< MutDynImage< TPredicate, TAllocator > > tryFromFormat(ImageLayout const &layout, PixelFormat const &pixel_format)
Tries to create image from provided size and format. Returns error if format does not satisfy TPredic...
Definition: mut_dyn_image.h:63
static auto makeCopyFrom(ImageView< TT > image_view) -> MutDynImage
Definition: mut_dyn_image.h:88
Definition: mut_dyn_image.h:23
#define SOPHUS_ASSERT(...)
Definition: common.h:40
MutDynImage(ImageSize const &size, PixelFormat const &pixel_format)
Definition: mut_dyn_image.h:132
static Expected< DynImage< TPredicate, TAllocator > > tryFromFormat(ImageSize const &size, PixelFormat const &pixel_format)
Tries to create image from provided size and format. Returns error if format does not satisfy TPredic...
Definition: mut_dyn_image.h:53
uint8_t const * ptr_
Definition: dyn_image_view.h:148
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
#define SOPHUS_UNWRAP(...)
Definition: common.h:52
Image MutImage, owning images types.
Definition: num_diff.h:20
MutDynImage()=default
Empty image.
auto has() const noexcept -> bool
Return true is this contains data of type TPixel.
Definition: mut_dyn_image.h:100
std::unique_ptr< uint8_t, MaybeLeakingUniqueDataAreaDeleter< TAllocator > > UniqueDataArea
Definition: mut_image.h:79
A view of an (immutable) image, which does not own the data.
Definition: image_view.h:55
auto moveOutAs() noexcept -> MutImage< TPixel, TAllocator >
Returns typed MutImage.
Definition: mut_dyn_image.h:109
void setViewToEmpty()
Definition: dyn_image_view.h:114
Definition: mut_image.h:53
ImageLayout layout_
Definition: dyn_image_view.h:146
A image with write access to pixels and exclusive ownership. There is no copy constr / copy assignmen...
Definition: image_view.h:32
auto width() const -> int
Definition: dyn_image_view.h:63
PixelFormat pixel_format_
Definition: dyn_image_view.h:147
#define SOPHUS_UNEXPECTED(...)
Definition: common.h:57
static auto makeCopyFrom(DynImageView< TPredicate > image_view) -> MutDynImage
Definition: mut_dyn_image.h:92
auto operator=(MutDynImage const &) -> MutDynImage &=delete
Not copy assignable.
UniqueDataArea< TAllocator > unique_
MutImage has unique ownership.
Definition: mut_image.h:218
MutDynImage(MutImage< TPixel, TAllocator > &&image)
Create type-erased image from MutImage.
Definition: mut_dyn_image.h:42
static MutDynImage< TPredicate, TAllocator > fromFormat(ImageSize const &size, PixelFormat const &pixel_format)
Definition: mut_dyn_image.h:74
MutDynImage(ImageLayout const &layout, PixelFormat const &pixel_format)
Definition: mut_dyn_image.h:141
Definition: mut_image.h:32
void copyDataFrom(DynImageView< TPredicate > view) const
Copies data from view into this.
Definition: mut_dyn_image_view.h:88
static auto makeCopyFrom(ImageView< TPixel > const &view) -> MutImage
Creates contiguous copy from view.
Definition: mut_image.h:124
UniqueDataArea< TAllocator > unique_
Definition: mut_dyn_image.h:154
Type-erased image with shared ownership, and read-only access to pixels. Type is nullable.
Definition: dyn_image.h:24
auto sizeBytes() const -> size_t
Definition: layout.h:62
MutDynImage(ImageLayout layout, PixelFormat pixel_format, UniqueDataArea< TAllocator > unique)
Definition: mut_dyn_image.h:125
static DynImage< TPredicate, TAllocator > fromFormat(ImageLayout const &layout, PixelFormat const &pixel_format)
Definition: mut_dyn_image.h:82
Image size, hence its width and height.
Definition: image_size.h:21
Definition: mut_dyn_image_view.h:18
Definition: dyn_image_view.h:29