Skip to content

OleBialas/headpose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Purpose

This package offers classes and methods for pose estimation on images. This can be done either with deep learning based facial landmark detection or by detecting ArUco markers.

Installation

Get the latest published version: pip install headpose
or install directly from GitHub: pip install git+https://github.com/OleBialas/headpose.git To use landmark detection you additionally have to install pytorch and torchvision

Example

import cv2
from headpose.detect 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()

est.detect_landmarks(image, plot=True)  # plot the result of landmark detection
roll, pitch, yawn = est.pose_from_image(image)  # estimate the head pose


Sources & Further Reading

This blog post nicely explained the concepts and mathematics behind pose estimation and this tutorial walks through the single steps of detecting facial landmarks with pytorch