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.

SDK.draw_face_box_and_landmarks(self: tfsdk.SDK, tf_image: tfsdk.TFImage, face_box_and_landmarks: tfsdk.FaceBoxAndLandmarks, include_landmarks: bool = False, color: tfsdk.ColorRGB = <tfsdk.ColorRGB object at 0x7f0655f61370>, scale: int = 2)tfsdk.ERRORCODE

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

Parameters
  • tf_image – the input tfsdk.TFImage, returned by tfsdk.SDK.preprocess_image().

  • face_box_and_landmarks – the face to annotate.

  • include_landmarks – indicates if the 5 keypoint landmarks should also be drawn.

  • color – the color to use for the annotation (default = ColorRGB(0, 255, 255).

Scale

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
SDK.draw_face_landmarks(self: tfsdk.SDK, tf_image: tfsdk.TFImage, landmarks: List[tfsdk.Point[106]], color: tfsdk.ColorRGB = <tfsdk.ColorRGB object at 0x7f0655f614f0>, scale: int = 2)tfsdk.ERRORCODE

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

Parameters
Scale

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

Returns

Error code, see ERRORCODE.

_images/face_landmarks_demo.gif
SDK.draw_head_orientation_axes(self: tfsdk.SDK, tf_image: tfsdk.TFImage, face_box_and_landmarks: tfsdk.FaceBoxAndLandmarks, yaw: float, pitch: float, roll: float, scale: int = 2)tfsdk.ERRORCODE

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

Parameters

Parameters
  • tf_image – the input tfsdk.TFImage, returned by tfsdk.SDK.preprocess_image().

  • face_box_and_landmarks – the face for which the orientation axes will be drawn.

  • yaw – the yaw in radians.

  • pitch – the pitch in radians.

  • roll – the roll in radians.

Scale

sale factor for the axis line thickness and length. Increase scale factor for higher resolution images.

Returns

Error code, see ERRORCODE.

_images/face_pose_axes_demo.gif
SDK.draw_head_orientation_box(self: tfsdk.SDK, tf_image: tfsdk.TFImage, rotation_vec: List[float[3]], translation_vec: List[float[3]], scale: int = 2)tfsdk.ERRORCODE

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

Parameters

Parameters
  • tf_image – the input tfsdk.TFImage, returned by tfsdk.SDK.preprocess_image().

  • rotation_vec – the rotation vector, returned by tfsdk.estimate_head_orientation().

  • translation_vec – the translation vector, returned by tfsdk.estimate_head_orientation().

Scale

sale factor for the box line thickness. Increase scale factor for higher resolution images.

Returns

Error code, see ERRORCODE.

_images/face_pose_box_demo.gif
SDK.draw_candidate_bounding_box_and_label(self: tfsdk.SDK, tf_image: tfsdk.TFImage, face_box_and_landmarks: tfsdk.FaceBoxAndLandmarks, candidate: tfsdk.Candidate, color: tfsdk.ColorRGB = <tfsdk.ColorRGB object at 0x7f0655f615f0>, scale: int = 2)tfsdk.ERRORCODE

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

Parameters
  • tf_image – the input tfsdk.TFImage, returned by tfsdk.SDK.preprocess_image().

  • face_box_and_landmarks – the face to annotate.

  • candidate – the candidate information.

  • color – the color to use for the annotation (default = ColorRGB(255, 255, 255).

Scale

scale factor for the bounding box thickness. Increase scale factor for higher resolution images.

Returns

Error code, see ERRORCODE.

_images/face_recognition_demo.gif
SDK.draw_object_labels(self: tfsdk.SDK, tf_image: tfsdk.TFImage, bounding_boxes: List[tfsdk.BoundingBox], scale: int = 2)tfsdk.ERRORCODE

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

Parameters
Returns

Error code, see ERRORCODE.

SDK.draw_pose(self: tfsdk.SDK, tf_image: tfsdk.TFImage, landmarks: List[List[tfsdk.Landmark]])tfsdk.ERRORCODE
Draw body pose on the image.

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

Parameters
class tfsdk.ColorRGB
property b

Blue channel.

property g

Green channel.

property r

Red channel.

ColorRGB.__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: tfsdk.ColorRGB) -> None

  2. __init__(self: tfsdk.ColorRGB, r: int, g: int, b: int) -> None