tool

OpenFace face analysis tool.

Functions

gaze_vector_2d

Projects the gaze vector in 2D starting from the center of the eye.

Classes

OpenFaceTool

OpenFace face analysis tool.

class OpenFaceTool(device='cpu', overwrite=False, verbose=True)[source]

Bases: FaceAnalysisTool

OpenFace face analysis tool.

Parameters:
  • overwrite (bool) – Whether to overwrite existing files, otherwise raise an error.

  • verbose (Union[bool, int]) – Whether to execute the computation verbosely.

  • device (str)

inference(video_path, features_path)[source]

Implementation of OpenFace’s face analysis inference method.

Parameters:
  • video_path (Union[str, Path]) – The path to the video file.

  • features_path (Union[str, Path]) – The path to the features archive.

Returns:

visualization(video_path, features_path, visualization_path, depth=3.0, f_x=None, f_y=None, c_x=None, c_y=None)[source]

Produces a visualization of the face pose and eye gaze vectors over a video.

Parameters:
  • video_path (Union[str, Path]) – The path to the video file.

  • features_path (Union[str, Path, list[Union[str, Path]]]) – The path or list of path to the features archive.

  • visualization_path (Union[str, Path]) – The path to the visualization file.

  • depth (Optional[float]) – The (guesstimated) depth between the camera and the subject.

  • f_x (Optional[float]) – The (guesstimated) focal length of the x-axis.

  • f_y (Optional[float]) – The (guesstimated) focal length of the y-axis.

  • c_x (Optional[float]) – The (guesstimated) principal point of the x-axis.

  • c_y (Optional[float]) – The (guesstimated) principal point of the x-axis.

Returns:

gaze_vector_2d(eye_2d, gaze_3d, depth, K, K_inverse)[source]

Projects the gaze vector in 2D starting from the center of the eye.

Parameters:
  • eye_2d (ndarray)

  • gaze_3d

  • depth (float)

  • K (ndarray)

  • K_inverse (ndarray)

Returns: