Skip to main content

PyGaze

PyGaze is a wrapper for the outstanding work of pytorch_mpiigaze_demo and eth-xgaze to provide a simple api to estimate the gaze of humans, either on images or in realtime.

Gaze

Buy Me A Coffee

Installation

pip install pygaze

API

  • First create an instance of PyGaze.
  • Call predict on the instance to get a list of faces in the image and a gaze vector.
  • To render information extracted from an image, instanciate PyGazeRenderer and call render() according to the examples.

Example usage

from pygaze import PyGaze, PyGazeRenderer
import cv2

image = cv2.imread("jonas.jpg")
pg = PyGaze()
pgren = PyGazeRenderer()
gaze_result = pg.predict(image)
for face in gaze_result:
    print(f"Face bounding box: {face.bbox}")
    pitch, yaw, roll = face.get_head_angles()
    g_pitch, g_yaw = face.get_gaze_angles()
    print(f"Face angles: pitch={pitch}, yaw={yaw}, roll={roll}.")
    print(f"Distance to camera: {face.distance}")
    print(f"Gaze angles: pitch={g_pitch}, yaw={g_yaw}")
    print(f"Gaze vector: {face.gaze_vector}")
    print(f"Looking at camera: {pg.look_at_camera(face)}")
	
    img = pgren.render(image, face, draw_face_bbox=True, draw_face_landmarks=False, draw_3dface_model=False,draw_head_pose=False, draw_gaze_vector=True)
    cv2.imshow("Face", img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

Todo

  • Add a flag to predict() to pass already detected faces in an image.

Release files for pygaze 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pygaze 1.2.2
File Interpreter ABI Platform
pygaze-1.2.2-py3-none-any.whl Python 3 none any Details

Release files / pygaze-1.2.2-py3-none-any.whl

Download URL pygaze-1.2.2-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8301ea10780c51b9a2bf69322538f867167bebf5aa09f967b868be34622a372
BLAKE2b-256 checksum
How to use checksums
291632d187eb5cac032a8ab62159d3a22ae21ed9e5abba65cc47589a15e631c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

1.2.2 This release

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page