4 #include <fsdk/Types/Format.h>
5 #include <fsdk/Types/Rect.h>
6 #include <fsdk/Types/Result.h>
7 #include <fsdk/Types/RotationType.h>
8 #include <fsdk/Types/Sizer.h>
9 #include <fsdk/Types/SubImage.h>
43 enum class Type : uint8_t {
153 int deviceId = 0) noexcept;
179 int deviceId = 0) noexcept;
222 int deviceId = 0) noexcept;
245 int deviceId = 0) noexcept;
273 int deviceId = 0) noexcept;
310 int deviceId = 0) noexcept;
340 int deviceId = 0) noexcept;
378 return map(rect.x, rect.y, rect.width, rect.height);
403 return map(origin.x, origin.y, size.x, size.y);
430 return extract(rect.x, rect.y, rect.width, rect.height);
457 return extract(origin.x, origin.y, size.x, size.y);
526 return convert(dest, origin.x, origin.y, size.x, size.y, format, device);
744 const uint32_t sizeInBytes,
746 const
Format format) noexcept;
813 template <typename T>
822 template <
typename T>
841 template <
typename T>
843 return reinterpret_cast<T*
>(
getData());
848 template <
typename T>
850 return reinterpret_cast<const T*
>(
getData());
911 return getData() == other.getData();
918 std::swap(
m_data, other.m_data);
919 std::swap(
m_ref, other.m_ref);
920 std::swap(
m_height, other.m_height);
921 std::swap(
m_width, other.m_width);
922 std::swap(
m_format, other.m_format);
923 std::swap(m_residence, other.m_residence);
939 m_residence == other.getMemoryResidence();
999 static const char* toString(
Image::Error error) noexcept {
1004 return "Unsupported type";
1006 return "Invalid path";
1008 return "Error during image saving";
1010 return "Error during image loading";
1012 return "Invalid image";
1014 return "Invalid image width";
1016 return "Invalid image height";
1018 return "Unsupported format";
1020 return "Memory error";
1022 return "Bitmap error";
1024 return "Archive error";
1026 return "Bad input data pointer";
1028 return "Bad input data size";
1030 return "Required conversion not implemented";
1032 return "Selected Target Device is not supported for this system";
1034 return "Error during initialization";
1036 return "Failed to retain image: it was released in another thread.";
1038 return "Unknown error";
medium compression (only for png or jpg)
Error during apply cuda kernel.
#define FSDK_API
Dummy.
Definition: Def.h:27
FSDK_API Result< Error > loadFromMemory(const void *data, const uint32_t sizeInBytes) noexcept
Load image from memory.
float getAspectRatio() const noexcept
Definition: Image.h:869
A structure that encapsulates an action result enumeration.
Definition: Result.h:27
void reset() noexcept
Reset image contents.
Definition: Image.h:928
static FSDK_API void deallocate(void *memory) noexcept
Free memory.
bool equalStrong(const fsdk::Image &other) const noexcept
Performs strong comparison of this image with other. Beside weak comparison strong comparison also ch...
Definition: Image.h:947
Vector2< int > Point2i
Definition: Vector2.h:294
Rect getRect() const noexcept
Definition: Image.h:894
Image in NPU PreProcessing module memory.
Type height
Rectangle height.
Definition: Rect.h:15
int m_height
image height.
Definition: Image.h:956
FSDK_API Result< Image::Error > convert(Image &dest, int x, int y, int width, int height, Format format, TargetDevice device=TargetDevice::CPU) const noexcept
Convert image format.
maximum compression level (only for png or jpg)
bool isNull() const noexcept
Definition: Image.h:770
Bad path for saving / loading.
FSDK_API Result< Error > load(const char *path) noexcept
Load image from file.
void * getData() noexcept
Definition: Image.h:829
Result< Image::Error > const noexcept
Convert image format.
Definition: Image.h:546
Format getFormat() const noexcept
Definition: Image.h:874
const void * getData() const noexcept
Definition: Image.h:835
const T * getDataAs() const noexcept
Definition: Image.h:849
FSDK_API Result< Image::Error > saveToMemory(Image::Type type, IArchive *archive, fsdk::Image::ImageCompression additionalFlag=fsdk::Image::ImageCompression::IC_NO_COMPRESSION) const noexcept
Save image to memory buffer.
FSDK_API Result< Error > set(int width, int height, Format format, const void *data, MemoryResidence residence=MemoryResidence::MemoryCPU, int deviceId=0) noexcept
Initializes an image with provided data. If current image is not empty and it's size and format match...
int getRowSize() const noexcept
Definition: Image.h:854
T * getScanLineAs(int y) noexcept
Get image scanline data.
Definition: Image.h:814
FSDK_API Image extract(int x, int y, int width, int height) const noexcept
Extract a sub image of this image. The new image will have it's own reference count.
RotationType
Image rotation type.
Definition: RotationType.h:10
FSDK_API Image rescale(float scale) const noexcept
Rescale image keeping proportions.
MemoryResidence
Memory residence.
Definition: Image.h:107
int getHeight() const noexcept
Definition: Image.h:864
Type width
Rectangle width.
Definition: Rect.h:14
Conversion not implemented.
Format m_format
image format (
Definition: Image.h:959
Invalid memory residence.
SubImage map(const Size &size) const noexcept
Map image contents to a given area.
Definition: Image.h:390
bool isSharedWith(const Image &other) const noexcept
Definition: Image.h:910
void * m_data
raw image data.
Definition: Image.h:954
FSDK_API Result< Error > create(int width, int height, Format format, bool cleanup=true, MemoryResidence residence=MemoryResidence::MemoryCPU, int deviceId=0) noexcept
Initializes an empty image and preallocates storage buffer of given size.
int * m_ref
reference counter. nullptr if image does not own data.
Definition: Image.h:955
const T * getScanLineAs(int y) const noexcept
Get image scanline data.
Definition: Image.h:823
FSDK_API int getRefCount() const noexcept
Obtain reference count.
Error during image saving.
int m_deviceId
id of the device where image memory is allocated
Definition: Image.h:958
FSDK_API SubImage map(int x, int y, int width, int height) const noexcept
Map image contents to a given area.
Image extract(const Point2i &origin, const Size &size) const noexcept
Extract a sub image of this image. The new image will have it's own reference count.
Definition: Image.h:456
static FSDK_API void * allocate(int size) noexcept
Allocate memory.
Type
Supported image types.
Definition: Image.h:43
bool equalWeak(const fsdk::Image &other) const noexcept
Performs weak comparison of this image with other. Weak in this context means only image parameters s...
Definition: Image.h:937
void swap(Image &other) noexcept
Swap contents with another image.
Definition: Image.h:917
Error during image loading.
Failed to retain image: it was released in another thread.
int m_width
image width.
Definition: Image.h:957
Image in Cuda device memory.
ImageCompression
Supported compression type is used only for jpg and png types.
Definition: Image.h:68
Image.
Definition: Image.h:38
T * getDataAs() noexcept
Definition: Image.h:842
FSDK_API int getDataSize() const noexcept
Target Device is not supported for this system.
FSDK_API int release() noexcept
Decrease reference count.
Image in Host device memory.
no compression (only for png or jpg image)
Archive interface.
Definition: IObject.h:38
SubImage map(const Point2i &origin, const Size &size) const noexcept
Map image contents to a given area.
Definition: Image.h:402
FSDK_API Result< Error > rotate(Image &dest, RotationType rotationType) const noexcept
Rotates an image on 90, 180 and 270 degrees. Allocates a new buffer of given size and fills image con...
Image extract(const Size &size) const noexcept
Extract a sub image of this image. The new image will have it's own reference count.
Definition: Image.h:443
FSDK_API Result< Error > loadFromMemoryOfType(const void *data, const uint32_t sizeInBytes, const Type type) noexcept
Load image from memory of specific type.
FSDK_API void * getScanLine(int y) noexcept
Get image scanline data.
Error
Image error codes.
Definition: Image.h:79
bool ownsData() const noexcept
Definition: Image.h:902
Sub Image.
Definition: SubImage.h:13
Result< Image::Error > convert(Image &dest, Format format, TargetDevice device=TargetDevice::CPU) const noexcept
Convert image format.
Definition: Image.h:580
FSDK_API Image() noexcept
Initializes an empty image.
more than medium compression (only for png or jpg)
Error during initialization.
Image clone() const noexcept
Create a copy of this image. The new image will have it's own reference count.
Definition: Image.h:475
FSDK_API Result< Image::Error > save(const char *path, fsdk::Image::ImageCompression additionalFlag=fsdk::Image::ImageCompression::IC_NO_COMPRESSION) const noexcept
Save image.
TargetDevice
Target device that fsdk::Image algorithms will be running on.
Definition: Image.h:55
Image extract(const Rect &rect) const noexcept
Extract a sub image of this image. The new image will have it's own reference count.
Definition: Image.h:429
Helper entity to measure size of dynamic objects in memory.
Definition: Sizer.h:9
FSDK_API int retain() noexcept
Increase reference count.
Vector2< int > Size
Definition: Vector2.h:303
Size getSize() const noexcept
Definition: Image.h:887
Image & operator=(Image &&other) noexcept
Move other image.
Definition: Image.h:760
Type y
Upper left corner y-coordinate.
Definition: Rect.h:13
int getWidth() const noexcept
Definition: Image.h:859
Image in NPU device memory.
Type x
Upper left corner x-coordinate.
Definition: Rect.h:12
bool isValid() const noexcept
Definition: Image.h:777
static FSDK_API Result< Error > guessTypeFromMemory(const void *data, const uint32_t sizeInBytes, Type &type) noexcept
Guess type of image written into memory.