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 {
134 int deviceId = 0) noexcept;
154 int deviceId = 0) noexcept;
180 int deviceId = 0) noexcept;
223 int deviceId = 0) noexcept;
246 int deviceId = 0) noexcept;
274 int deviceId = 0) noexcept;
311 int deviceId = 0) noexcept;
341 int deviceId = 0) noexcept;
379 return map(rect.x, rect.y, rect.width, rect.height);
404 return map(origin.x, origin.y, size.x, size.y);
470 return extract(rect.x, rect.y, rect.width, rect.height);
499 return extract(origin.x, origin.y, size.x, size.y);
546 TargetDevice device = TargetDevice::CPU)
const noexcept;
567 TargetDevice device = TargetDevice::CPU)
const noexcept {
568 return convert(dest, origin.x, origin.y, size.x, size.y, format, device);
608 return convert(dest, rect.x, rect.y, rect.width, rect.height, format, device);
646 fsdk::Image::ImageCompression::IC_NO_COMPRESSION)
const noexcept;
674 fsdk::Image::ImageCompression::IC_NO_COMPRESSION)
const noexcept;
786 const uint32_t sizeInBytes,
788 const Format format)
noexcept;
826 operator bool() const noexcept {
855 template <typename T>
864 template <
typename T>
883 template <
typename T>
885 return reinterpret_cast<T*
>(
getData());
890 template <
typename T>
892 return reinterpret_cast<const T*
>(
getData());
924 int getDeviceId() const noexcept {
953 return getData() == other.getData();
960 std::swap(
m_data, other.m_data);
961 std::swap(
m_ref, other.m_ref);
962 std::swap(
m_height, other.m_height);
963 std::swap(
m_width, other.m_width);
964 std::swap(
m_format, other.m_format);
965 std::swap(m_residence, other.m_residence);
981 m_residence == other.getMemoryResidence();
993 FSDK_API void putPixel(uint32_t x, uint32_t y)
noexcept;
1052 return "Unsupported type";
1054 return "Invalid path";
1056 return "Error during image saving";
1058 return "Error during image loading";
1060 return "Invalid image";
1062 return "Invalid image width";
1064 return "Invalid image height";
1066 return "Unsupported format";
1068 return "Memory error";
1070 return "Bitmap error";
1072 return "Archive error";
1074 return "Bad input data pointer";
1076 return "Bad input data size";
1078 return "Required conversion not implemented";
1080 return "Selected Target Device is not supported for this system";
1082 return "Error during initialization";
1084 return "Failed to retain image: it was released in another thread.";
1086 return "InvalidInput";
1088 return "Unknown error";
#define FSDK_API
Dummy.
Definition Def.h:27
SDK namespace.
Definition IAGSEstimator.h:8
RotationType
Image rotation type.
Definition RotationType.h:10
Vector2< int > Size
Definition Vector2.h:303
Vector2< int > Point2i
Definition Vector2.h:294
const char * toString(Image::MemoryResidence residence)
Returns a string representation of a MemoryResidence type.
Archive interface.
Definition IObject.h:38
Image.
Definition Image.h:38
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:498
int getRowSize() const noexcept
Definition Image.h:896
Result< Image::Error > convert(Image &dest, const Rect &rect, Format format, TargetDevice device=TargetDevice::CPU) const noexcept
Convert image format.
Definition Image.h:606
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:979
float getAspectRatio() const noexcept
Definition Image.h:911
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_width
image width.
Definition Image.h:999
FSDK_API int release() noexcept
Decrease reference count.
const T * getDataAs() const noexcept
Definition Image.h:891
bool isSharedWith(const Image &other) const noexcept
Definition Image.h:952
void * getData() noexcept
Definition Image.h:871
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.
void * m_data
raw image data.
Definition Image.h:996
static FSDK_API Result< Error > guessTypeFromMemory(const void *data, const uint32_t sizeInBytes, Type &type) noexcept
Guess type of image written into memory.
Format getFormat() const noexcept
Definition Image.h:916
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:989
FSDK_API Result< Image::Error > extract(Image &dest, const Rect &rect) const noexcept
Extract a sub image of this image. The new image will have it's own reference count.
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:469
FSDK_API Result< Error > load(const char *path, const Format format) noexcept
Load image from file and convert it to required format.
bool isValid() const noexcept
Definition Image.h:819
int * m_ref
reference counter. nullptr if image does not own data.
Definition Image.h:997
FSDK_API int getRefCount() const noexcept
Obtain reference count.
Result< Image::Error > convert(Image &dest, const Size &size, Format format, TargetDevice device=TargetDevice::CPU) const noexcept
Convert image format.
Definition Image.h:587
FSDK_API Result< Error > loadFromMemoryOfType(const void *data, const uint32_t sizeInBytes, const Type type) noexcept
Load image from memory of specific type.
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:484
Image & operator=(Image &&other) noexcept
Move other image.
Definition Image.h:802
Image clone() const noexcept
Create a copy of this image. The new image will have it's own reference count.
Definition Image.h:517
Rect getRect() const noexcept
Definition Image.h:936
T * getScanLineAs(int y) noexcept
Get image scanline data.
Definition Image.h:856
SubImage map(const Point2i &origin, const Size &size) const noexcept
Map image contents to a given area.
Definition Image.h:403
int getWidth() const noexcept
Definition Image.h:901
void swap(Image &other) noexcept
Swap contents with another image.
Definition Image.h:959
FSDK_API Image rescale(float scale) const noexcept
Rescale image keeping proportions.
FSDK_API void * getScanLine(int y) noexcept
Get image scanline data.
static FSDK_API void deallocate(void *memory) noexcept
Free memory.
FSDK_API Result< Error > loadFromMemoryOfType(const void *data, const uint32_t sizeInBytes, const Type type, const Format format) noexcept
Load image from memory of specific type and convert it to required format.
Error
Image error codes.
Definition Image.h:79
@ ReleasedInOtherThread
Failed to retain image: it was released in another thread.
@ FailedToLoad
Error during image loading.
@ InvalidDataSize
Bad input data size.
@ InvalidImage
Invalid image.
@ InvalidResidence
Invalid memory residence.
@ InvalidDevice
Target Device is not supported for this system.
@ InvalidArchive
Archive error.
@ InvalidDataPtr
Bad input data pointer.
@ InvalidPath
Bad path for saving / loading.
@ InvalidWidth
Invalid width.
@ FailedToSave
Error during image saving.
@ InvalidMemory
Error at memory opening.
@ InvalidConversion
Conversion not implemented.
@ InvalidHeight
Invalid height.
@ InvalidBitmap
Bitmap error occurred.
@ InvalidType
Unsupported type.
@ InvalidInput
Invalid input.
@ InvalidFormat
Unsupported format.
@ FailedToInitialize
Error during initialization.
@ InvalidCudaKernel
Error during apply cuda kernel.
static FSDK_API void * allocate(int size) noexcept
Allocate memory.
const void * getData() const noexcept
Definition Image.h:877
int m_deviceId
id of the device where image memory is allocated
Definition Image.h:1000
Image & operator=(const Image &other) noexcept
Assign other image.
Definition Image.h:793
FSDK_API Result< Error > loadFromMemory(const void *data, const uint32_t sizeInBytes, const Format format) noexcept
Load image from memory and convert it to required format.
Result< Image::Error > convert(Image &dest, const Point2i &origin, const Size &size, Format format, TargetDevice device=TargetDevice::CPU) const noexcept
Convert image format.
Definition Image.h:562
TargetDevice
Target device that fsdk::Image algorithms will be running on.
Definition Image.h:55
FSDK_API Result< Error > rescale(Image &dest, float scale) const noexcept
Rescale image keeping proportions.
T * getDataAs() noexcept
Definition Image.h:884
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...
bool isNull() const noexcept
Definition Image.h:812
const T * getScanLineAs(int y) const noexcept
Get image scanline data.
Definition Image.h:865
FSDK_API Result< Image::Error > extract(Image &dest, 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.
SubImage map(const Size &size) const noexcept
Map image contents to a given area.
Definition Image.h:391
int m_height
image height.
Definition Image.h:998
Result< Image::Error > convert(Image &dest, Format format, TargetDevice device=TargetDevice::CPU) const noexcept
Convert image format.
Definition Image.h:622
FSDK_API int retain() noexcept
Increase reference count.
void reset() noexcept
Reset image contents.
Definition Image.h:970
FSDK_API Result< Image::Error > save(const char *path, fsdk::Image::ImageCompression additionalFlag=fsdk::Image::ImageCompression::IC_NO_COMPRESSION) const noexcept
Save image.
FSDK_API Result< Image::Error > saveToMemory(Image::Type type, IArchive *archive, const Format format) const noexcept
Convert and save image to memory buffer.
FSDK_API const void * getScanLine(int y) const noexcept
Get image scanline data.
MemoryResidence
Memory residence.
Definition Image.h:108
@ MemoryNPU_DPP
Image in NPU PreProcessing module memory.
@ MemoryCPU
Image in Host device memory.
@ MemoryNPU
Image in NPU device memory.
@ MemoryGPU
Image in Cuda device memory.
Size getSize() const noexcept
Definition Image.h:929
FSDK_API Result< Error > save(const char *path, const Format format) const noexcept
Convert and Save image.
ImageCompression
Supported compression type is used only for jpg and png types.
Definition Image.h:68
@ IC_HARD_COMPRESSION
more than medium compression (only for png or jpg)
@ IC_NO_COMPRESSION
no compression (only for png or jpg image)
@ IC_BEST_COMPRESSION
maximum compression level (only for png or jpg)
@ IC_SMALL_COMPRESSION
image)
@ IC_MEDIUM_COMPRESSION
medium compression (only for png or jpg)
FSDK_API Image() noexcept
Initializes an empty image.
FSDK_API Result< Error > load(const char *path) noexcept
Load image from file.
int getHeight() const noexcept
Definition Image.h:906
Type
Supported image types.
Definition Image.h:43
FSDK_API int getDataSize() const noexcept
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...
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.
bool ownsData() const noexcept
Definition Image.h:944
FSDK_API SubImage map(int x, int y, int width, int height) const noexcept
Map image contents to a given area.
Format m_format
image format (
Definition Image.h:1001
FSDK_API Result< Error > loadFromMemory(const void *data, const uint32_t sizeInBytes) noexcept
Load image from memory.
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.
A structure that encapsulates an action result enumeration.
Definition Result.h:27
Helper entity to measure size of dynamic objects in memory.
Definition Sizer.h:9
Sub Image.
Definition SubImage.h:13