Face Engine SDK
5.8.0
A face detection, recognition and tracking engine.
|
#include <Image.h>
Public Member Functions | |
FSDK_API | Image () noexcept |
Initializes an empty image. | |
FSDK_API | Image (int width, int height, Format format, MemoryResidence residence=MemoryResidence::MemoryCPU, int deviceId=0) noexcept |
Initializes an empty image and preallocates storage buffer of given size. More... | |
FSDK_API | Image (int width, int height, Format format, const void *data, MemoryResidence residence=MemoryResidence::MemoryCPU, int deviceId=0) noexcept |
Initializes an empty image and preallocates storage buffer of given size. Fills image contents with provided data. More... | |
FSDK_API | Image (int width, int height, Format format, void *data, bool copy, MemoryResidence residence=MemoryResidence::MemoryCPU, int deviceId=0) noexcept |
Initializes an image. If copy is true, this allocates a new buffer of given size and fills image contents with provided data (copies it). If copy is false (which is default) this will just reference the provided data. More... | |
FSDK_API | Image (const Image &other) noexcept |
Initializes an image as a reference to an other image. More... | |
FSDK_API | Image (Image &&other) noexcept |
Initializes an image with contents of an other image. Source image is then invalidated. More... | |
FSDK_API | Image (const SubImage &subImage) noexcept |
Initializes an image with contents of a sub image. Since sub images do not handle data life time, image contents are always copied. More... | |
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. More... | |
FSDK_API Result< Error > | create (int width, int height, Format format, const void *data, MemoryResidence residence=MemoryResidence::MemoryCPU, int deviceId=0) noexcept |
Initializes an empty image and preallocates storage buffer of given size. Fills image contents with provided data. More... | |
FSDK_API Result< Error > | create (int width, int height, Format format, void *data, bool copy, MemoryResidence residence=MemoryResidence::MemoryCPU, int deviceId=0) noexcept |
Initializes an image. If copy is true, this allocates a new buffer of given size and fills image contents with provided data (copies it). If copy is false (which is default) this will just reference the provided data. More... | |
FSDK_API Result< Error > | create (const fsdk::Image &source, MemoryResidence residence, int deviceId=0) noexcept |
Creates image with given memory residence based on other image instance. If source image has another MemoryResidence or device id, all memory will be copied to the new residence. In the other case new instance will be just a reference for the source. More... | |
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 the provided ones, no memory reallocation is performed. Otherwise image is re-created to match requirements. More... | |
FSDK_API Result< Error > | set (int width, int height, Format format, void *data, bool copy, MemoryResidence residence=MemoryResidence::MemoryCPU, int deviceId=0) noexcept |
Initializes an image with provided data. If copy is true and if current image is not empty and it's size and format match the provided ones, no memory reallocation is performed. Otherwise image is re-created to match requirements. If copy is false (which is default) this will just reference the provided data. More... | |
FSDK_API Result< Error > | set (const Image &other) noexcept |
Initializes an image as a reference to an other image. More... | |
FSDK_API Result< Error > | set (const SubImage &subImage) noexcept |
Initializes an image with contents of a sub image. Since sub images do not handle data life time, image contents are always copied. More... | |
FSDK_API SubImage | map (int x, int y, int width, int height) const noexcept |
Map image contents to a given area. More... | |
SubImage | map (const Rect &rect) const noexcept |
Map image contents to a given area. More... | |
SubImage | map (const Size &size) const noexcept |
Map image contents to a given area. More... | |
SubImage | map (const Point2i &origin, const Size &size) const noexcept |
Map image contents to a given area. More... | |
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. More... | |
Image | extract (const Rect &rect) const noexcept |
Extract a sub image of this image. The new image will have it's own reference count. More... | |
Image | extract (const Size &size) const noexcept |
Extract a sub image of this image. The new image will have it's own reference count. More... | |
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. More... | |
Image | clone () const noexcept |
Create a copy of this image. The new image will have it's own reference count. More... | |
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. More... | |
Result< Image::Error > | convert (Image &dest, const Point2i &origin, const Size &size, Format format, TargetDevice device=TargetDevice::CPU) const noexcept |
Convert image format. More... | |
Result< Image::Error > | convert (Image &dest, const Size &size, Format format, TargetDevice device=TargetDevice::CPU) const noexcept |
Convert image format. More... | |
Result< Image::Error > | convert (Image &dest, const Rect &rect, Format format, TargetDevice device=TargetDevice::CPU) const noexcept |
Convert image format. More... | |
Result< Image::Error > | convert (Image &dest, Format format, TargetDevice device=TargetDevice::CPU) const noexcept |
Convert image format. More... | |
FSDK_API Image | rescale (float scale) const noexcept |
Rescale image keeping proportions. More... | |
FSDK_API Result< Image::Error > | save (const char *path, fsdk::Image::ImageCompression additionalFlag=fsdk::Image::ImageCompression::IC_NO_COMPRESSION) const noexcept |
Save image. More... | |
FSDK_API Result< Error > | save (const char *path, const Format format) const noexcept |
Convert and Save image. More... | |
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. More... | |
FSDK_API Result< Image::Error > | saveToMemory (Image::Type type, IArchive *archive, const Format format) const noexcept |
Convert and save image to memory buffer. More... | |
FSDK_API Result< Error > | load (const char *path) noexcept |
Load image from file. More... | |
FSDK_API Result< Error > | load (const char *path, const Format format) noexcept |
Load image from file and convert it to required format. More... | |
FSDK_API Result< Error > | loadFromMemory (const void *data, const uint32_t sizeInBytes) noexcept |
Load image from memory. More... | |
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. More... | |
FSDK_API Result< Error > | loadFromMemoryOfType (const void *data, const uint32_t sizeInBytes, const Type type) noexcept |
Load image from memory of specific type. More... | |
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. More... | |
Image & | operator= (const Image &other) noexcept |
Assign other image. More... | |
Image & | operator= (Image &&other) noexcept |
Move other image. More... | |
bool | isNull () const noexcept |
bool | isValid () const noexcept |
operator bool () const noexcept | |
Implicit cast to boolean; results in true if image is valid, false if not. More... | |
FSDK_API void * | getScanLine (int y) noexcept |
Get image scanline data. More... | |
FSDK_API const void * | getScanLine (int y) const noexcept |
Get image scanline data. More... | |
FSDK_API int | getDataSize () const noexcept |
FSDK_API void | getDataSize (Sizer &sizer) const noexcept |
Get actual image size in bytes. More... | |
template<typename T > | |
T * | getScanLineAs (int y) noexcept |
Get image scanline data. More... | |
template<typename T > | |
const T * | getScanLineAs (int y) const noexcept |
Get image scanline data. More... | |
void * | getData () noexcept |
const void * | getData () const noexcept |
template<typename T > | |
T * | getDataAs () noexcept |
template<typename T > | |
const T * | getDataAs () const noexcept |
int | getRowSize () const noexcept |
int | getWidth () const noexcept |
int | getHeight () const noexcept |
float | getAspectRatio () const noexcept |
Format | getFormat () const noexcept |
MemoryResidence | getMemoryResidence () const noexcept |
int | getDeviceId () const noexcept |
Size | getSize () const noexcept |
Rect | getRect () const noexcept |
bool | ownsData () const noexcept |
bool | isSharedWith (const Image &other) const noexcept |
void | swap (Image &other) noexcept |
Swap contents with another image. More... | |
void | reset () noexcept |
Reset image contents. | |
bool | equalWeak (const fsdk::Image &other) noexcept |
Performs weak comparison of this image with other. Weak in this context means only image parameters should be equal i.e width, height, format and residence. Actual data pointer of two images might differ. | |
bool | equalStrong (const fsdk::Image &other) noexcept |
Performs strong comparison of this image with other. Beside weak comparison strong comparison also checks whether two images point to the same block of pixels. More... | |
FSDK_API void | putPixel (uint32_t x, uint32_t y) noexcept |
Static Public Member Functions | |
static FSDK_API Result< Error > | guessTypeFromMemory (const void *data, const uint32_t sizeInBytes, Type &type) noexcept |
Guess type of image written into memory. More... | |
Protected Member Functions | |
FSDK_API int | retain () noexcept |
Increase reference count. More... | |
FSDK_API int | release () noexcept |
Decrease reference count. More... | |
FSDK_API int | getRefCount () const noexcept |
Obtain reference count. More... | |
Static Protected Member Functions | |
static FSDK_API void * | allocate (int size) noexcept |
Allocate memory. More... | |
static FSDK_API void | deallocate (void *memory) noexcept |
Free memory. More... | |
Protected Attributes | |
void * | m_data |
raw image data. | |
int * | m_ref |
reference counter. nullptr if image does not own data. | |
int | m_height |
image height. | |
int | m_width |
image width. | |
int | m_deviceId |
id of the device where image memory is allocated | |
Format | m_format |
image format ( More... | |
MemoryResidence | m_residence |
Image objects embed an implicit reference counter to automatically track consumers perform assignments without unnecessary reallocations in a thread-safe manner.
Every time you assign or set an other image as the source of the current image, the current image data reference count is decreased, new data pointer is referenced, and it's counter is increased. When data reference count drops to zero, the data is deallocated.
Image can also reference external data without an actual ownership. This way you can operate on your data buffer using methods of Image and still own it and cotrol it's life time.
|
strong |
Image error codes.
Enumerator | |
---|---|
Ok |
Ok. |
InvalidWidth |
Invalid width. |
InvalidHeight |
Invalid height. |
InvalidDataPtr |
Bad input data pointer. |
InvalidDataSize |
Bad input data size. |
InvalidImage |
Invalid image. |
InvalidArchive |
Archive error. |
InvalidPath |
Bad path for saving / loading. |
InvalidType |
Unsupported type.
|
InvalidFormat |
Unsupported format.
|
InvalidBitmap |
Bitmap error occurred. |
InvalidMemory |
Error at memory opening. |
InvalidConversion |
Conversion not implemented. |
InvalidResidence |
Invalid memory residence. |
InvalidDevice |
Target Device is not supported for this system. |
FailedToSave |
Error during image saving. |
FailedToLoad |
Error during image loading. |
FailedToInitialize |
Error during initialization. |
ReleasedInOtherThread |
Failed to retain image: it was released in another thread. |
|
strong |
Supported compression type is used only for jpg and png types.
JPG case: the higher level of compression corresponds to the lower quality. Compression/decompression speed are constant. PNG case: the higher level of compression corresponds to the lower compression speed. Quality are constant.
|
strong |
Memory residence.
Enumerator | |
---|---|
MemoryCPU |
Image in Host device memory. |
MemoryGPU |
Image in Cuda device memory. |
MemoryNPU |
Image in NPU device memory. |
MemoryNPU_DPP |
Image in NPU PreProcessing module memory. |
|
noexcept |
Initializes an empty image and preallocates storage buffer of given size.
[in] | width | image width. |
[in] | height | image height. |
[in] | format | image format. |
[in] | deviceId | index of a device where image will be allocated |
|
noexcept |
Initializes an empty image and preallocates storage buffer of given size. Fills image contents with provided data.
[in] | width | image width. |
[in] | height | image height. |
[in] | format | image format. |
[in] | data | image data. |
[in] | deviceId | index of a device where image will be allocated |
|
noexcept |
Initializes an image. If copy is true, this allocates a new buffer of given size and fills image contents with provided data (copies it). If copy is false (which is default) this will just reference the provided data.
[in] | width | image width. |
[in] | height | image height. |
[in] | format | image format. |
[in] | data | image data. |
[in] | copy | [optional] whether to copy or reference data. |
[in] | deviceId | index of a device where image will be allocated |
Initializes an image as a reference to an other image.
[in] | other | other image. |
Initializes an image with contents of an other image. Source image is then invalidated.
[in] | other | other image. |
Initializes an image with contents of a sub image. Since sub images do not handle data life time, image contents are always copied.
[in] | subImage | sub image. |
|
staticprotectednoexcept |
Allocate memory.
[in] | size | memory region size in bytes. |
|
inlinenoexcept |
Create a copy of this image. The new image will have it's own reference count.
|
noexcept |
Convert image format.
[in,out] | dest | destination image. |
[in] | x | horisontal coordinate of top left corner of image rect to convert. |
[in] | y | vertical coordinate of top left corner of image rect to convert. |
[in] | width | width of image rect to convert. |
[in] | height | height of image rect to convert. |
[in] | format | new format. |
[in] | device | target device to run convert on. |
|
inlinenoexcept |
Convert image format.
[in,out] | dest | destination image. |
[in] | origin | converted image origin. |
[in] | size | image size to convert. |
[in] | format | new format. |
[in] | device | target device to run convert on. |
|
inlinenoexcept |
Convert image format.
[in,out] | dest | destination image. |
[in] | format | new format. |
[in] | size | image area size to convert. |
[in] | device | target device to run convert on. |
|
inlinenoexcept |
Convert image format.
[in,out] | dest | destination image. |
[in] | format | new format. |
[in] | rect | image area rect to convert. |
[in] | device | target device to run convert on. |
|
inlinenoexcept |
Convert image format.
[in,out] | dest | destination image. |
[in] | format | new format. |
[in] | device | target device to run convert on. |
|
noexcept |
Initializes an empty image and preallocates storage buffer of given size.
[in] | width | image width. |
[in] | height | image height. |
[in] | format | image format. |
[in] | cleanup | initializes internal image memory to default value. |
[in] | residence | memory residence of a data pointer. |
[in] | deviceId | index of a device where image will be allocated |
|
noexcept |
Initializes an empty image and preallocates storage buffer of given size. Fills image contents with provided data.
[in] | width | image width. |
[in] | height | image height. |
[in] | format | image format. |
[in] | data | image data. |
[in] | memory | residence of a data pointer. |
[in] | deviceId | index of a device where data pointer was allocated |
|
noexcept |
Initializes an image. If copy is true, this allocates a new buffer of given size and fills image contents with provided data (copies it). If copy is false (which is default) this will just reference the provided data.
[in] | width | image width. |
[in] | height | image height. |
[in] | format | image format. |
[in] | data | image data. |
[in] | copy | whether to copy or reference data |
[in] | memory | residence of a data pointer. |
[in] | deviceId | index of a device where data pointer was allocated |
|
noexcept |
Creates image with given memory residence based on other image instance. If source image has another MemoryResidence or device id, all memory will be copied to the new residence. In the other case new instance will be just a reference for the source.
[in] | image | instance to create copy for |
[in] | residence | memory residence for the target image |
[in] | deviceId | index of a device for the target image |
|
staticprotectednoexcept |
Free memory.
[in] | memory | memory region pointer. |
|
inlinenoexcept |
Performs strong comparison of this image with other. Beside weak comparison strong comparison also checks whether two images point to the same block of pixels.
Extract a sub image of this image. The new image will have it's own reference count.
[in] | x | horisontal coordinate of top left corner of image rect to extract. |
[in] | y | vertical coordinate of top left corner of image rect to extract. |
[in] | width | width of image rect to extract. |
[in] | height | height of image rect to extract. |
Extract a sub image of this image. The new image will have it's own reference count.
[in] | rect | image rect to extract. |
Extract a sub image of this image. The new image will have it's own reference count.
[in] | size | image size to extract. |
Extract a sub image of this image. The new image will have it's own reference count.
[in] | origin | extracted image origin. |
[in] | size | image size to extract. |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
Get actual image size in bytes.
[in,out] | sizer | sizer to append result to. |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
protectednoexcept |
Obtain reference count.
|
inlinenoexcept |
|
noexcept |
Get image scanline data.
[in] | y | scanline number. |
|
noexcept |
Get image scanline data.
[in] | y | scanline number. |
|
inlinenoexcept |
Get image scanline data.
[in] | y | scanline number. |
|
inlinenoexcept |
Get image scanline data.
[in] | y | scanline number. |
|
inlinenoexcept |
|
inlinenoexcept |
|
staticnoexcept |
Guess type of image written into memory.
[in] | data | Pointer to memory containing image. |
[in] | sizeInBytes | Count of bytes containing image pointed to by data. |
[out] | type | Type of passed image. |
|
inlinenoexcept |
|
inlinenoexcept |
[in] | other | other image to check againts. |
|
inlinenoexcept |
Load image from file.
This function loads image contents from disk. Supported types are: bmp, png, ppm, jpeg, tiff. If image is not empty, it's content will be freed and memory will be reallocated to fit in the data from the file if:
[in] | path | Input file path. |
Load image from file and convert it to required format.
This function does exact same thing as method above, and additionally converts loaded image to input format.
[in] | path | Input file path. |
[in] | format | required image format. |
|
noexcept |
Load image from memory.
This function loads image contents from memory. Supported types are: bmp, png, ppm, jpeg, tiff. If image is not empty, it's content will be freed and memory will be reallocated to fit in the data from the file if:
[in] | data | Pointer to input memory. |
[in] | sizeInBytes | Count of bytes of image pointed to by data. |
|
noexcept |
Load image from memory and convert it to required format.
This function does exact same thing as method above, and additionally converts loaded image to input format.
[in] | data | Pointer to input memory. |
[in] | sizeInBytes | Count of bytes of image pointed to by data. |
[in] | format | required image format. |
|
noexcept |
Load image from memory of specific type.
This function loads specific type image contents from memory. If data points to image of another type, not the one passed, does nothing. Supported types are: bmp, png, ppm, jpeg, tiff. If image is not empty, it's content will be freed and memory will be reallocated to fit in the data from the file if:
[in] | data | Pointer to input memory. |
[in] | sizeInBytes | Count of bytes of image pointed to by data. |
[in] | type | Type of image to be loaded. |
|
noexcept |
Load image from memory of specific type and convert it to required format.
This function does exact same thing as method above, and additionally converts loaded image to input format.
[in] | data | Pointer to input memory. |
[in] | sizeInBytes | Count of bytes of image pointed to by data. |
[in] | type | Type of image to be loaded. |
[in] | format | required image format. |
Map image contents to a given area.
[in] | x | horizontal coordinate of top left corner of image rect to map. |
[in] | y | vertical coordinate of top left corner of image rect to map. |
[in] | width | width of image rect to map |
[in] | height | height of image rect to map |
Map image contents to a given area.
[in] | rect | image rect to extract |
Map image contents to a given area.
[in] | size | image size to map. |
Map image contents to a given area.
[in] | origin | sub image image origin. |
[in] | size | sub image size to extract. |
|
inlinenoexcept |
Implicit cast to boolean; results in true if image is valid, false if not.
Assign other image.
[in] | other | image to assign. |
Move other image.
[in] | other | image to move. |
|
inlinenoexcept |
|
protectednoexcept |
Decrease reference count.
Rescale image keeping proportions.
[in] | scale | factor. Must be positive. |
|
protectednoexcept |
Increase reference count.
|
noexcept |
Save image.
This function saves image contents to disk. Type is extracted from provided file extension. If it is unknown, function fails. Supported types are: bmp, png, ppm, jpeg, tiff.
[in] | path | output file path with proper file extension. |
[in] | additionalFlag | additional flag for saving of png or jpg image |
Convert and Save image.
This function converts image to required format and saves image contents to disk. Type is extracted from provided file extension. If it is unknown, function fails. Supported types are: bmp, png, ppm, jpeg, tiff.
[in] | path | output file path with proper file extension. |
[in] | format | required image format. |
|
noexcept |
Save image to memory buffer.
This function saves image contents to memory buffer (IArchive). Passed IArchvie will call setSizeHint for resize.
[in] | Image::Type | format used to encode. |
[in] | IArchive | to store contents of encoded image. |
[in] | additionalFlag | additional flag for saving of png or jpg image |
|
noexcept |
Convert and save image to memory buffer.
This function converts image to required format and saves image contents to memory buffer (IArchive). Passed IArchvie will call setSizeHint for resize.
[in] | Image::Type | format used to encode. |
[in] | IArchive | to store contents of encoded image. |
[in] | format | required image format. |
|
noexcept |
Initializes an image with provided data. If current image is not empty and it's size and format match the provided ones, no memory reallocation is performed. Otherwise image is re-created to match requirements.
[in] | width | image width. |
[in] | height | image height. |
[in] | format | image format. |
[in] | data | image data. |
[in] | memory | residence of a data pointer. |
[in] | deviceId | index of a device where data pointer was allocated |
|
noexcept |
Initializes an image with provided data. If copy is true and if current image is not empty and it's size and format match the provided ones, no memory reallocation is performed. Otherwise image is re-created to match requirements. If copy is false (which is default) this will just reference the provided data.
[in] | width | image width. |
[in] | height | image height. |
[in] | format | image format. |
[in] | data | image data. |
[in] | copy | whether to copy or reference data. |
[in] | memory | residence of a data pointer. |
[in] | deviceId | index of a device where data pointer was allocated |
Initializes an image as a reference to an other image.
[in] | other | other image. |
Initializes an image with contents of a sub image. Since sub images do not handle data life time, image contents are always copied.
[in] | subImage | sub image. |
|
inlinenoexcept |
Swap contents with another image.
[in,out] | other | image to swap with. |