ExtractedFaces

class tools.alignments.media.ExtractedFaces(frames: Frames, alignments: AlignmentData, size: int = 512)

Bases: object

Holds the extracted faces and matrix for alignments

Parameters:
  • frames (Frames) – The frames object to extract faces from

  • alignments (AlignmentData) – The alignment data corresponding to the frames

  • size (int) – The extract face size. Default: 512

Methods Summary

extract_one_face(alignment, image)

Extract one face from image

get_faces(frame[, image])

Obtain faces and transformed landmarks for each face in a given frame with its alignments

get_faces_in_frame(frame[, update, image])

Return the faces for the selected frame

get_roi_size_for_frame(frame)

Return the size of the original extract box for the selected frame.

Methods Documentation

extract_one_face(alignment: FileAlignments, image: np.ndarray) DetectedFace

Extract one face from image

Parameters:
  • alignment (FileAlignments) – The alignment for a single face

  • image (np.ndarray) – The image to extract the face from

Return type:

The detected face object for the given alignment with the aligned face loaded

get_faces(frame: str, image: np.ndarray | None = None) None

Obtain faces and transformed landmarks for each face in a given frame with its alignments

Parameters:
  • frame (str) – The frame name to obtain faces for

  • image (np.ndarray | None) – The image to extract the face from, if we already have it, otherwise None to load the image. Default: None

Return type:

None

get_faces_in_frame(frame: str, update: bool = False, image: np.ndarray | None = None) list[DetectedFace]

Return the faces for the selected frame

Parameters:
  • frame (str) – The frame name to get the faces for

  • update (bool) – True if the faces should be refreshed regardless of current frame. False to not force a refresh. Default False

  • image (np.ndarray | None) – Image to load faces from if it exists, otherwise None to load the image. Default: None

Returns:

  • List of DetectedFace objects for the frame, with the aligned face

  • loaded

Return type:

list[DetectedFace]

get_roi_size_for_frame(frame: str) list[int]

Return the size of the original extract box for the selected frame.

Parameters:

frame (str) – The frame to obtain the original sized bounding boxes for

Return type:

List of original pixel sizes of faces held within the frame

extract_one_face(alignment: FileAlignments, image: np.ndarray) DetectedFace

Extract one face from image

Parameters:
  • alignment (FileAlignments) – The alignment for a single face

  • image (np.ndarray) – The image to extract the face from

Return type:

The detected face object for the given alignment with the aligned face loaded

get_faces(frame: str, image: np.ndarray | None = None) None

Obtain faces and transformed landmarks for each face in a given frame with its alignments

Parameters:
  • frame (str) – The frame name to obtain faces for

  • image (np.ndarray | None) – The image to extract the face from, if we already have it, otherwise None to load the image. Default: None

Return type:

None

get_faces_in_frame(frame: str, update: bool = False, image: np.ndarray | None = None) list[DetectedFace]

Return the faces for the selected frame

Parameters:
  • frame (str) – The frame name to get the faces for

  • update (bool) – True if the faces should be refreshed regardless of current frame. False to not force a refresh. Default False

  • image (np.ndarray | None) – Image to load faces from if it exists, otherwise None to load the image. Default: None

Returns:

  • List of DetectedFace objects for the frame, with the aligned face

  • loaded

Return type:

list[DetectedFace]

get_roi_size_for_frame(frame: str) list[int]

Return the size of the original extract box for the selected frame.

Parameters:

frame (str) – The frame to obtain the original sized bounding boxes for

Return type:

List of original pixel sizes of faces held within the frame