Image Annotation

Methods for annotating images with face landmarks, bounding boxes, face recognition labels, and more. After annotating an image, you must not run inference functions on that image. You can call multiple annotation methods on the same image.

ErrorCode Trueface::SDK::drawFaceBoxAndLandmarks(const TFImage &tfImage, const FaceBoxAndLandmarks &faceBoxAndLandmarks, bool includeLandmarks = false, const ColorRGB &color = ColorRGB(0, 255, 255), unsigned int scale = 2)

Draw face detection bounding box and 5 keypoint landmarks. Note, you should not run any inference functions on the image after calling this method.

Parameters
  • tfImage[in] the input image on which to draw the labels.

  • faceBoxAndLandmarks[in] the face to annotate.

  • includeLandmarks[in] indicates if the 5 keypoint landmarks should also be drawn.

  • color[in] the color to use for the annotation.

  • scale[in] scale factor for the bounding box thickness. Increase scale factor for higher resolution images.

Returns

error code, see ErrorCode.

../_images/face_box_and_landmarks_demo.gif
ErrorCode Trueface::SDK::drawFaceLandmarks(const TFImage &tfImage, const Landmarks &landmarks, const ColorRGB &color = ColorRGB(0, 255, 255), unsigned int scale = 2)

Draw the 106 face landmarks on the face image. Note, you should not run any inference functions on the image after calling this method.

Parameters
  • tfImage[in] the input image on which to draw the landmarks.

  • landmarks[in] the 106 face landmarks.

  • color[in] the color to use for the annotation.

  • scale[in] size of the landmark points draw on the face. Increase scale factor for higher resolution images.

Returns

error code

../_images/face_landmarks_demo.gif
ErrorCode Trueface::SDK::drawHeadOrientationAxes(const TFImage &tfImage, const FaceBoxAndLandmarks &faceBoxAndLandmarks, float yaw, float pitch, float roll, unsigned int scale = 2)

Draw the 3D face orientation axes. Note, you should not run any inference functions on the image after calling this method.

Parameters
  • tfImage[in] the input image on which to draw the rotation axes.

  • faceBoxAndLandmarks[in] the face for which the orientation axes will be drawn.

  • yaw[in] the yaw in radians.

  • pitch[in] the pitch in radians.

  • roll[in] the roll in radians.

  • scale[in] the scale factor for the axis line thickness and length. Increase scale factor for higher resolution images.

Returns

error code.

../_images/face_pose_axes_demo.gif
ErrorCode Trueface::SDK::drawHeadOrientationBox(const TFImage &tfImage, const std::array<double, 3> &rotationVec, std::array<double, 3> &translationVec, unsigned int scale = 2)

Draw 3D box on the face. Note, you should not run any inference functions on the image after calling this method.

Parameters
  • tfImage[in] the input image on which to draw the rotation axes.

  • rotationVec[in] the rotation vector, returned by estimateHeadOrientation().

  • translationVec[in] the translation vector, returned by estimateHeadOrientation().

  • scale[in] the scale factor for the box line thickness. Increase scale factor for higher resolution images.

Returns

error code.

../_images/face_pose_box_demo.gif
ErrorCode Trueface::SDK::drawCandidateBoundingBoxAndLabel(const TFImage &tfImage, const FaceBoxAndLandmarks &faceBoxAndLandmarks, const Candidate &candidate, const ColorRGB &color = ColorRGB(0, 255, 0), unsigned int scale = 2)

Draw a bounding box around the face and a label containing the identity and match probability. Note, you should not run any inference functions on the image after calling this method.

Parameters
  • tfImage[in] the input image on which to draw the labels.

  • faceBoxAndLandmarks[in] the face to annotate.

  • candidate[in] the candidate information.

  • color[in] the color to use for the annotation.

  • scale[in] the scale factor for the text size and bounding box thickness. Increase scale factor for higher resolution images.

Returns

ErrorCode.

../_images/face_recognition_demo.gif
ErrorCode Trueface::SDK::drawObjectLabels(const TFImage &tfImage, const std::vector<BoundingBox> &boundingBoxes, unsigned int scale = 2)

Draw object detector bounding boxes and labels on the image. Note, you should not run any inference functions on the image after calling this method.

Parameters
  • tfImage[in] the input image on which to draw the labels.

  • boundingBoxes[in] the bounding boxes returned by detectObjects().

  • scale[in] scale factor for the text size and bounding box thickness. Increase scale factor for higher resolution images.

Returns

error code, see ErrorCode.

ErrorCode Trueface::SDK::drawPose(const TFImage &tfImage, const std::vector<std::vector<Landmark>> &landmarks)

Draw body pose on the image. Note, you should not run any inference functions on the image after calling this method.

Parameters
  • tfImage[in] the input image on which to draw the pose.

  • landmarks[in] a vector of Landmark objects that represent body joints.

Returns

error code, see ErrorCode.

struct Trueface::ColorRGB

Struct used to define colors. Values must be between [0, 255] inclusive.

Public Functions

ColorRGB() = default

Default constructor.

inline ColorRGB(uint8_t r, uint8_t g, uint8_t b)

Construct from provided rgb values.

Public Members

uint8_t r = 0

Red channel

uint8_t g = 0

Green channel

uint8_t b = 0

Blue channel