Input Image¶
In order to use many of the Trueface AI inference functions (face detection, face recognition, etc), you must first set the image.
The SDK is stateful meaning that once you set the image, it will persist until the next call to tfsdk.SDK.set_image()
is made.
This means that you can set the image once then call various functions on that same image.
Once you have set the image, you are ready to start calling the various Trueface AI inference functions.
-
SDK.
set_image
(*args, **kwargs)¶ Overloaded function.
set_image(self: tfsdk.SDK, pixel_array: numpy.ndarray[uint8], width: int, height: int, color_code: tfsdk.COLORCODE) -> tfsdk.ERRORCODE
Load an image from the given pixel array in memory. Note, it is highly encouraged to check the return value from setImage before proceeding. If the license is invalid, the
tfsdk.ERRORCODE.INVALID_LICENSE
error will be returned.set_image(self: tfsdk.SDK, pointer: int, width: int, height: int, color_code: tfsdk.COLORCODE, stride: int) -> tfsdk.ERRORCODE
Load an image from the given memory pointer. Note, it is highly encouraged to check the return value from setImage before proceeding. If the license is invalid, the
tfsdk.ERRORCODE.INVALID_LICENSE
error will be returned.- Parameters
pointer - pointer to decoded pixel array in memory.
width - the image width in pixels.
height - the image height in pixels.
color_code - the pixel array color code, see
COLORCODE
.stride - 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
set_image(self: tfsdk.SDK, image_filepath: str) -> tfsdk.ERRORCODE
Load an image from the given JPEG, JPG, PNG, BMP, or TIFF file. Note, it is highly encouraged to check the return value from setImage before proceeding. If the license is invalid, the
tfsdk.ERRORCODE.INVALID_LICENSE
error will be returned.- Parameters
image_filepath - the path to the image. Must not contain “~”. Can be a relative path.
- Returns
Error code, see
ERRORCODE
set_image(self: tfsdk.SDK, encoded_image_buffer: List[int]) -> tfsdk.ERRORCODE
Load an image from an encoded image buffer, supports JPG, PNG, BMP, and TIFF. Note, it is highly encouraged to check the return value from setImage before proceeding. If the license is invalid, the
tfsdk.ERRORCODE.INVALID_LICENSE
error will be returned.- Parameters
encoded_image_buffer - encoded image buffer, supports JPG, PNG, BMP, and TIFF.
- Returns
Error code, see
ERRORCODE
You can set the image using an OpenCV cv::Mat
by passing the image buffer as follows:
1 2 | cv_img = cv2.imread(img_path)
res = sdk.set_image(cv_img, cv_img.shape[1], cv_img.shape[0], tfsdk.COLORCODE.bgr)
|
-
class
tfsdk.
COLORCODE
¶ Members:
bgr
rgb
bgra
rgba
gray
yuv_i420
yuv_nv12