Input Image¶
In order to use many of the Trueface AI inference functions (face detection, face recognition, etc), you must first preprocess your image. Once you have preprocessed your image, you are ready to start calling the various Trueface AI inference functions.
-
class Image¶
Class which is used to manage a decoded image which is in the format expected by inference functions. Should populate Image using the preprocessImage functions. An Image can be in CPU memory or GPU memory.
-
void Trueface::Image::rotate(double rotAngleDegrees)¶
Rotate the image.
- Parameters
rotAngleDegrees – rotation angle in degrees. Positive values mean counter-clockwise rotation (the coordinate origin is assumed to be the top-left corner).
-
void Trueface::Image::saveImage(const std::string &filepath)¶
Save the preprocessed image to disk.
- Parameters
filepath – the filepath where the image should be saved, including the image extension
-
unsigned int Trueface::Image::getHeight()¶
Get the image height in pixels.
- Returns
Returns the image height in pixels.
-
unsigned int Trueface::Image::getWidth()¶
Get the image width in pixels.
- Returns
Returns the image width in pixels.
-
bool Trueface::Image::isManagedBuffer()¶
Is the memory managed by the class. If the memory is managed by the class, the image data will be freed when the instance storage duration ends. If the memory is not managed by the class, then it is up to the user to free the allocated memory.
- Returns
Returns true if the memory is managed by the class.
-
bool Trueface::Image::isGPUImage()¶
Is the imagine in GPU memory.
- Returns
Returns true if the image is in GPU memory.
-
uint8_t *Trueface::Image::getData()¶
Get the decoded image buffer.
- Returns
Returns the decoded image buffer.
-
ErrorCode Trueface::SDK::preprocessImage(const std::string &imageFile, TFImage &tfImage)¶
Preprocess the image to be used by the other methods.
- Parameters
imageFile – [in] the path of a JPEG, JPG, PNG, BMP, or TIFF file (path must not contain ~ ).
tfImage – [out] the preprocesses image.
- Returns
error code, see ErrorCode.
-
ErrorCode Trueface::SDK::preprocessImage(uint8_t *image, uint16_t width, uint16_t height, ColorCode color, TFImage &tfImage, int stride = 0)¶
Preprocess the image to be used by the other methods. Creates a copy of the image buffer.
- Parameters
image – [in] an 8-bit decoded image array, in the CPU memory or the GPU memory.
width – [in] the image width.
height – [in] the image height.
color – [in] the image color model, see ColorCode.
tfImage – [out] the preprocesses image.
stride – [in] the distance between image array rows in bytes, also known as step size (used only for pointers to the GPU memory).
- Returns
error code, see ErrorCode.
-
ErrorCode Trueface::SDK::preprocessImage(const std::vector<uint8_t> &encodedImageBuffer, TFImage &tfImage)¶
Preprocess the image to be used by the other methods.
- Parameters
encodedImageBuffer – [in] encoded image buffer, supports JPG, PNG, BMP, and TIFF.
tfImage – [out] the preprocesses image.
- Returns
error code, see ErrorCode.
-
ErrorCode Trueface::SDK::preprocessRgbImage(uint8_t *image, uint16_t width, uint16_t height, TFImage &tfImage, int stride = 0)¶
Preprocess the image to be used by other methods. Buffer is not copied and memory should be managed by the caller. More efficient than preprocessImage() as the data is referenced and not copied. Buffer must remain valid until the TFImage is no longer needed, at which point the caller is responsible for freeing the allocated memory.
- Parameters
image – an 8-bit decoded image array in RGB format, in the CPU memory or the GPU memory.
width – the image width.
height – the image height.
tfImage – the preprocessed image.
stride – the distance between image array rows in bytes, also known as step size (used only for pointers to the GPU memory).
- Returns