Go to the documentation of this file.
22 class TPredicate = AnyImagePredicate,
23 class TAllocator = Eigen::aligned_allocator<uint8_t>>
34 template <
class TPixel>
40 static_assert(TPredicate::template isTypeValid<TPixel>());
45 template <
class TPixel>
48 static_assert(TPredicate::template isTypeValid<TPixel>());
56 image.unique_.reset();
57 image.setViewToEmpty();
65 FARM_TRY(
auto, mut, Mut::tryFromFormat(size, pixel_format));
92 if (!TPredicate::isFormatValid(pixel_format)) {
98 template <
class TOtherPredicate>
100 -> Expected<DynImage<TPredicate, TAllocator>> {
101 if (!TPredicate::isFormatValid(other_image.pixelFormat())) {
105 other_image.layout(), other_image.pixelFormat(), other_image.shared_);
109 template <
class TPixel>
110 [[nodiscard]]
auto has() const noexcept ->
bool {
111 PixelFormat expected_type = PixelFormat::fromTemplate<TPixel>();
118 template <
class TPixel>
119 [[nodiscard]]
auto image() const noexcept ->
Image<TPixel, TAllocator> {
120 if (!this->has<TPixel>()) {
121 PixelFormat expected_type = PixelFormat::fromTemplate<TPixel>();
124 "expected type: {}\n"
136 template <
class TPixel>
140 reinterpreted_size.width *
sizeof(TPixel), this->layout().pitch_bytes_);
149 template <
class TPredicate2,
class TAllocator2T>
156 std::shared_ptr<uint8_t> shared)
auto reinterpretAs(ImageSize reinterpreted_size) const noexcept -> Image< TPixel, TAllocator >
Definition: dyn_image.h:137
DynImage(MutDynImage< TPredicate, TAllocator > &&image)
Create type-erased image from MutImage. By design not "explicit".
Definition: dyn_image.h:53
#define SOPHUS_PANIC(...)
Definition: common.h:50
Definition: mut_dyn_image.h:23
std::shared_ptr< uint8_t > shared_
Definition: dyn_image.h:160
#define FARM_TRY(Type, var, expression)
Assigns *expression to var of Type, but returns error if there is one.
Definition: expected.h:91
auto has() const noexcept -> bool
Return true is this contains data of type TPixel.
Definition: dyn_image.h:110
auto layout() const -> ImageLayout const &
Definition: dyn_image_view.h:56
Image read-only access to pixels and shared ownership, hence cheap to copy. Type is nullable.
Definition: image.h:31
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
auto useCount() const -> size_t
Definition: dyn_image.h:146
A view of an (immutable) image, which does not own the data.
Definition: image_view.h:55
DynImage(ImageLayout layout, PixelFormat pixel_format, std::shared_ptr< uint8_t > shared)
Definition: dyn_image.h:153
#define SOPHUS_UNIMPLEMENTED(...)
Definition: common.h:51
friend class DynImage
Definition: dyn_image.h:150
static DynImage< TPredicate, TAllocator > fromFormat(ImageSize const &size, PixelFormat const &pixel_format)
Definition: dyn_image.h:73
ImageLayout layout_
Definition: dyn_image_view.h:146
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: dyn_image.h:62
static Expected< DynImage< 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: dyn_image.h:90
A image with write access to pixels and exclusive ownership. There is no copy constr / copy assignmen...
Definition: image_view.h:32
PixelFormat pixel_format_
Definition: dyn_image_view.h:147
#define SOPHUS_UNEXPECTED(...)
Definition: common.h:57
#define SOPHUS_ASSERT_LE(...)
Definition: common.h:44
static auto tryFrom(DynImage< TOtherPredicate, TAllocator > other_image) -> Expected< DynImage< TPredicate, TAllocator >>
Definition: dyn_image.h:99
static DynImage< TPredicate, TAllocator > fromFormat(ImageLayout const &layout, PixelFormat const &pixel_format)
Definition: dyn_image.h:82
DynImage(MutImage< TPixel > &&image)
Create type-erased image from MutImage. By design not "explicit".
Definition: dyn_image.h:46
DynImage(Image< TPixel, TAllocator > const &image)
Create type-erased image from Image.
Definition: dyn_image.h:35
Type-erased image with shared ownership, and read-only access to pixels. Type is nullable.
Definition: dyn_image.h:24
auto image() const noexcept -> Image< TPixel, TAllocator >
Returns typed image.
Definition: dyn_image.h:119
Image size, hence its width and height.
Definition: image_size.h:21
Definition: dyn_image_view.h:29