Face mesh generator using the Face Mesh Mediapipe model with a CPU delegate written in C++
- Plain C/C++ implementation with minimal dependencies (Tensorflow Lite + OpenCV)
- Google MediaPipe models without the MediaPipe framework
- Runs on ARM
This library offers support for:
- 3D Face Landmarking (468 points)
This is some example code for face landmarking:
/* Create instance of FaceMesh detector */
CLFML::FaceMesh::FaceMesh mesh_det;
/* Initialize model interpreter */
mesh_det.load_model(CFML_FACE_MESH_CPU_MODEL_PATH);
/* Load the image into the model and run inference */
mesh_det.load_image(cam_frame);
/* Get the 3D Face landmarks */
std::array<cv::Point3f, CLFML::FaceMesh::NUM_OF_FACE_MESH_POINTS> face_mesh_keypoints = mesh_det.get_face_mesh_points();
For a full example showcasing both these API functions see the example code in example/face_mesh_demo/demo.cpp.
Before using this library you will need the following packages installed:
- OpenCV
- Working C++ compiler (GCC, Clang, MSVC (2017 or Higher))
- CMake
- Ninja (Optional, but preferred)
- Clone this repo
- Run:
cmake . -B build -G Ninja
- Let CMake generate and run:
cd build && ninja
- After building you can run (linux & mac):
./face_mesh_demo
or (if using windows)
face_mesh_demo.exe
Add this to your top-level CMakeLists file:
include(FetchContent)
FetchContent_Declare(
face_mesh.cpp
GIT_REPOSITORY https://github.com/CLFML/Face_Mesh.Cpp
GIT_TAG main
# Put the Face_Mesh lib into lib/ folder
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/Face_Mesh.Cpp
)
FetchContent_MakeAvailable(face_mesh.cpp)
...
target_link_libraries(YOUR_EXECUTABLE CLFML::face_mesh)
Or manually clone this repo and add the library to your project using:
add_subdirectory(Face_Mesh.Cpp)
...
target_link_libraries(YOUR_EXECUTABLE CLFML::face_mesh)
Before using this library you will need the following packages installed:
- OpenCV
- ROS2
- ROS CV bridge
- Working C++ compiler (GCC or Clang)
- CMake
- Clone this repo:
git clone https://github.com/CLFML/Face_Mesh.Cpp.git
- Source your ROS2 installation:
source /opt/ros/jazzy/setup.bash
- Install the dependencies:
rosdep install --from-paths src -y --ignore-src
- Build the package:
colcon build --packages-select face_mesh
- Set up the environment:
source install/setup.bash
- Run the camera node:
ros2 run v4l2_camera v4l2_camera_node
- In another terminal, run the nodes
ros2 launch example/ros2/launch.py
See our wiki...
- Add language bindings for Python, C# and Java
- Add support for MakeFiles and Bazel
- Add Unit-tests
- Add support for the Face Mesh V2 model
This work is licensed under the Apache 2.0 license.
The face_mesh model is also licensed under the Apache 2.0 license.