Skip to main content

estimate the pose of the head based on an image.

Project description

Purpose

The purpose of this package is to provide a simple API to estimate the head pose based on a single image of a face.\

Installation

You can install the package via pip: pip install headpose
All the dependencies should be installed automatically. Note that the trained models are only compatible with tensorflow versions >2 and <2.4 (requires Python 3.5 - 3.8).

Head Pose Estimation

import cv2
from headpose import PoseEstimator

est = PoseEstimator()  #load the model
# take an image using the webcam (alternatively, you could load an image)
cam = cv2.VideoCapture(0)
for i in range(cv2.CAP_PROP_FRAME_COUNT):
    cam.grab()
ret, image = cam.retrieve()
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cam.release()

roll, pitch, yawn = est.pose_from_image(image)  # estimate the head pose
est.plot_face_detection_marks(image)  # plot the image with the face detection marks

Sources & Further Reading

The code is inspired by this blog post which does a good job explaining the steps which are performed to obtain the head pose. The pose estimation uses a deep neural network - the pretrained models are taken from this github repo. If you want to understand the math behind pose estimation, check out this tutorial

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

headpose-1.0.9.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

headpose-1.0.9-py3-none-any.whl (37.2 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page