← all repositories
ShiqiYu/libfacedetection

A face-detection CNN baked into plain C++ arrays

Why link against heavy ML frameworks when the whole model fits in a few C source files?

12.8k stars C++ Computer Vision
libfacedetection
Not currently ranked — collecting fresh signals.
star history

What it does

libfacedetection implements the YuNet CNN face detector as a self-contained C++ library. The entire trained model is serialized into static variables inside ordinary source files, so you can compile it on any platform with a standard C++ compiler—no GPU, no Python stack, and no external libraries required. It targets Intel and ARM CPUs directly, using AVX2 or NEON SIMD to drive throughput.

The interesting bit

By treating network weights as compile-time data, the project turns a face detector into a copy-paste dependency. It also provides an ONNX version of the same YuNet model for OpenCV DNN, though the two paths come with slightly different constraints.

Key highlights

  • Zero external dependencies; the model lives entirely in src/facedetectcnn-data.cpp.
  • Benchmarks on an Intel i7-7820X report multi-threaded speeds up to ~3,200 FPS at 128×96 with AVX512, and ~1,750 FPS at 160×120 with AVX2.
  • SIMD acceleration via AVX2 (x64) or NEON (ARM).
  • WIDER Face scores: AP_easy 0.887, AP_medium 0.871, AP_hard 0.768.
  • Runs on Windows, Linux, ARM, and anything else that speaks C++.

Caveats

  • OpenCV DNN does not support the latest YuNet with dynamic input shapes; you must match the ONNX model’s exact input dimensions.
  • The README notes a manual step: you may need to add a facedetection_export.h header with a #define when copying the source files into your project.
  • On a Raspberry Pi 4 B, performance tops out near 222 FPS at 128×96 across four cores, so “thousands of FPS” is strictly an x64 phenomenon.

Verdict

A strong fit for embedded or resource-constrained projects that need face detection without a full ML framework. If you plan to consume the model through OpenCV DNN, verify your input shape compatibility first.

Frequently asked

What is ShiqiYu/libfacedetection?
Why link against heavy ML frameworks when the whole model fits in a few C source files?
Is libfacedetection open source?
Yes — ShiqiYu/libfacedetection is an open-source project tracked on heatdrop.
What language is libfacedetection written in?
ShiqiYu/libfacedetection is primarily written in C++.
How popular is libfacedetection?
ShiqiYu/libfacedetection has 12.8k stars on GitHub.
Where can I find libfacedetection?
ShiqiYu/libfacedetection is on GitHub at https://github.com/ShiqiYu/libfacedetection.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.