• Stars
    star
    1,025
  • Rank 44,587 (Top 0.9 %)
  • Language
    Python
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Realtime human head pose estimation with ONNXRuntime and OpenCV.

Head pose estimation

Realtime human head pose estimation with ONNXRuntime and OpenCV.

demo demo

How it works

There are three major steps:

  1. Face detection. A face detector is introduced to provide a face bounding box containing a human face. Then the face box is expanded and transformed to a square to suit the needs of later steps.
  2. Facial landmark detection. A pre-trained deep learning model take the face image as input and output 68 facial landmarks.
  3. Pose estimation. After getting 68 facial landmarks, the pose could be calculated by a mutual PnP algorithm.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

The code was tested on Ubuntu 22.04 with following frameworks:

  • ONNXRuntime: 1.14.1
  • OpenCV: 4.5.4

Installing

Clone the repo:

git clone https://github.com/yinguobing/head-pose-estimation.git

Install dependencies with pip:

pip install -r requirements.txt

Note there are pre-trained models provided in the assets directory.

Running

A video file or a webcam index should be assigned through arguments. If no source provided, the built in webcam will be used by default.

Video file

For any video format that OpenCV supports (mp4, avi etc.):

python3 main.py --video /path/to/video.mp4

Webcam

The webcam index should be provided:

python3 main.py --cam 0

Retrain the model

Tutorials: https://yinguobing.com/deeplearning/

Training code: https://github.com/yinguobing/cnn-facial-landmark

Note: PyTorch version coming soon!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Meanwhile:

  • The face detector is SCRFD from InsightFace.
  • The pre-trained model file was trained with various public datasets which have their own licenses.

Please refer to them for details.

Authors

Yin Guobing (尹国冰) - yinguobing

Acknowledgments

All datasets used in the training process:

The 3D face model is from OpenFace, you can find the original file here.

The build in face detector is SCRFD from InsightFace.

More Repositories

1

cnn-facial-landmark

Training code for facial landmark detection based on deep convolutional neural network.
Python
609
star
2

facial-landmark-detection-hrnet

A TensorFlow implementation of HRNet for facial landmark detection.
Python
137
star
3

face-mesh-generator

Generate face mesh dataset using Google's FaceMesh model.
Python
110
star
4

facial-landmark-dataset

A collection of facial landmark datasets and Python code to make use of them.
Python
75
star
5

image_utility

Handy python scripts for image dataset processing.
Python
73
star
6

face-marks

Detect facial landmarks with TensorFlow and CoreML on iPhone.
Swift
73
star
7

arcface

A TensorFlow implementation of face recognition model ArcFace.
Python
44
star
8

tfrecord_utility

Generate and view TensorFlow's TFRecord file.
Python
29
star
9

YSUthesis

Master thesis template for Yanshan University
TeX
14
star
10

License-Plate-Generator

Generate random motor vehicle license plate images. 随机车牌生成器。
Python
13
star
11

blaze-face

A TensorFlow implementation of Google's BlazeFace
Python
11
star
12

models

A playground for friendly deep neural network models.
Python
10
star
13

butterfly

A lightweight python module to load TensorFlow frozen model (a single pb file).
Python
7
star
14

linglong

A human friendly implementation of TensorFlow face detection.
Python
7
star
15

yolov5-trt

YOLO v5 inference with TensorRT (C++)
C++
5
star
16

Playground

深度学习新手小广场(机器视觉主题)
Jupyter Notebook
4
star
17

open_images

Extract bounding boxes from Open Images dataset.
Jupyter Notebook
2
star
18

count-files

A simple command line tool to count all files in a directory.
Rust
1
star
19

pyACL_standalone_samples

Standalone samples for Python ACL (Ascend Computing Language) development.
Python
1
star
20

yinguobing

Hi, there!
1
star
21

make-it-glitch

Minimal C++ code for generating glitchy video with FFMPEG.
C++
1
star
22

efficientdet-runner

执行EfficientDet模型推演的最小代码模块
Python
1
star