pntt3011 / mediapipe_face_iris_cpp

Real-time Face and Iris Landmarks Detection using C++
GNU General Public License v3.0
81 stars 15 forks source link
cpp cpu face-landmark-detection iris-detection mediapipe-face-detection mediapipe-facemesh mediapipe-iris opencv real-time tflite

# Face + Iris Landmarks Real-time Detection in C++ (OpenCV + Tensorflow Lite)

(Note: This guide is for Windows OS, but the code should work fine on other OS, too)

This project runs on Mediapipe TFLite models without using Mediapipe framework. It can run at 90+ FPS on CPU. I perform the test on an AMD Ryzen 7 3700U Pro and the app takes about 5% CPU while running. For more information:

:warning: Why not using GPU ?

Because Tensorflow Lite only supports GPU delegate for Android and IOS. For more information: https://www.tensorflow.org/lite/performance/gpu

:computer: Requirements:

Hardware: Windows 10 64-bit

Visual Studio 2019

CMake >= 3.16

You can follow instructions at https://www.40tude.fr/compile-cpp-code-with-vscode-cmake-nmake/

OpenCV (for Demo)

How to install (Windows 64-bit) 1. Download and install pre-built binaries at https://sourceforge.net/projects/opencvlibrary/files/4.5.3/opencv-4.5.3-vc14_vc15.exe/download 2. Add `/build/x64/vc15/bin` and `/build/x64/vc15/lib` to PATH.

Since the prebuilt OPENCV libraries do not contain the 32-bit version, you will have to manually build it using cmake. https://docs.opencv.org/master/d3/d52/tutorial_windows_install.html

Tensorflow Lite

How to use pre-built library 1. Download and extract tensorflowlite.zip from https://github.com/shigure3011/mediapipe_face_iris_cpp/releases 2. Change `TFLite_PATH` in CMakeLists.txt 3. Add `TFLite_LIBS` to PATH

:key: How to use:

  1. Clone this repo and go to FaceMeshCpp folder
  2. Run cmake -S . -B build
  3. Run cmake --build build --config Release --target FaceMeshCpp
  4. Now it will build an .exe at ~/build/Release. Make sure to copy model folder to ~/build/Release/ before running.