As an open-source project, ShiqiYu/libfacedetection has picked up 12.8k stars on GitHub (C++). An open source library for face detection in images. The face detection speed can reach 1000FPS.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
This is an open source library for CNN-based face detection in images. The CNN model has been converted to static variables in C source files. The source code does not depend on any other libraries. What you need is just a C++ compiler. You can compile the source code under Windows, Linux, ARM and any platform with a C++ compiler.
SIMD instructions are used to speed up the detection. You can enable AVX2 if you use Intel CPU or NEON for ARM.
The model files are provided in src/facedetectcnn-data.cpp (C++ arrays) & the model (ONNX) from OpenCV Zoo. You can try our scripts (C++ & Python) in opencv_dnn/ with the ONNX model. View the network architecture here.
Please note that OpenCV DNN does not support the latest version of YuNet with dynamic input shape. Please ensure you have the exact same input shape as the one in the ONNX model to run latest YuNet with OpenCV DNN.
examples/detect-image.cpp and examples/detect-camera.cpp show how to use the library.
The library was trained by libfacedetection.train.
How to use the code
You can copy the files in directory src/ into your project,
and compile them as the other files in your project.
The source code is written in standard C/C++.
It should be compiled at any platform which supports C/C++.
Some tips:
Please add facedetection_export.h file in the position where you copy your facedetectcnn.h files, add #define FACEDETECTION_EXPORT to facedetection_export.h file. See: issues #222
Please add -O3 to turn on optimizations when you compile the source code using g++.
Please choose 'Maximize Speed/-O2' when you compile the source code using Microsoft Visual Studio.
You can enable OpenMP to speedup. But the best solution is to call the detection function in different threads.
You can also compile the source code to a static or dynamic library, and then use it in your project.
How to compile
CNN-based Face Detection on Intel CPU
Using AVX2 instructions
Method
Time
FPS
Time
FPS
X64
X64
X64
X64
Single-thread
Single-thread
Multi-thread
Multi-thread
cnn (CPU, 640x480)
50.02ms
19.99
6.55ms
152.65
cnn (CPU, 320x240)
13.09ms
76.39
1.82ms
550.54
cnn (CPU, 160x120)
3.61ms
277.37
0.57ms
1745.13
cnn (CPU, 128x96)
2.11ms
474.60
0.33ms
2994.23
Using AVX512 instructions
Method
Time
FPS
Time
FPS
X64
X64
X64
X64
Single-thread
Single-thread
Multi-thread
Multi-thread
cnn (CPU, 640x480)
46.47ms
21.52
6.39ms
156.47
cnn (CPU, 320x240)
12.10ms
82.67
1.67ms
599.31
cnn (CPU, 160x120)
3.37ms
296.47
0.46ms
2155.80
cnn (CPU, 128x96)
1.98ms
504.72
0.31ms
3198.63
Minimal face size ~10x10
Intel(R) Core(TM) i7-7820X CPU @ 3.60GHz
Multi-thread in 16 threads and 16 processors.
CNN-based Face Detection on ARM Linux (Raspberry Pi 4 B)
Run on default settings: scales=[1.], confidence_threshold=0.02, floating point:
AP_easy=0.887, AP_medium=0.871, AP_hard=0.768
Highway Optimized Version
An independent Highway-based implementation has been added under highway/.
It keeps the original implementation untouched and exposes a separate C API:
The Highway version follows the same deployment model as the original project:
build separately for each instruction set/platform. It does not currently use
Highway runtime dynamic dispatch. The current x86 performance path is:
Backend
Description
pure Highway
Portable Highway kernels for pointwise, depthwise, maxpool, image/network/postprocess flow
x86 hybrid AVX2
Highway packed pointwise plus guarded AVX2/FMA intrinsics for selected depthwise/maxpool ceiling kernels
The public API uses thread-local internal workspaces, so the recommended
multi-threading model is external parallelism: call facedetect_hw_cnn from
multiple threads, with one result buffer per calling thread.
Test CPU: Intel(R) Core(TM) i7-14700KF, 20 cores, 28 logical processors,
max clock reported by Windows: 3400 MHz.
Compiler/toolchain: Visual Studio 17 2022, MSVC 19.40.33821.0, Release build.
origin AVX2 was built with _ENABLE_AVX2; origin default/scalar was
built without original SIMD macros.
Highway scalar was built with FDT_HW_FORCE_SCALAR=ON.
External MT means external multi-threading with 28 caller threads and one
result buffer per thread. The reported time is throughput-normalized average
time per image.
AVX512 builds are buildable with /arch:AVX512, but cannot be run on the
test CPU, so no AVX512 timing is reported here.
ARM Linux has not been tested for the Highway version yet.
Existing ARM Linux numbers below are from the original implementation, not
the new Highway implementation.
See COMPILE.md and example/detect-image-highway.cpp /
example/benchmark-highway.cpp for build and usage examples.
Rust Crate
A pure Rust implementation is available under rust/ as the crate
libfacedetection_rs. It uses the same CNN model data, generated into Rust
source so the crate is self-contained and does not need to parse the C++ model
file at build time.
The Rust crate is intended for normal Rust dependency usage:
[dependencies]
libfacedetection_rs = "0.1"
Minimal usage:
use libfacedetection_rs::{image, Detector};
fn main() -> Result<(), libfacedetection_rs::DetectError> {
let image = image::open("face.jpg")?;
let mut detector = Detector::new();
let detection = detector.detect(&image)?;
println!("faces: {}", detection.face_count());
Ok(())
}
Test CPU: Intel(R) Core(TM) i7-14700KF, 20 cores, 28 logical processors,
max clock reported by Windows: 3400 MHz.
C++ compiler/toolchain: Visual Studio 17 2022, MSVC 19.40.33821.0, Release
build. The origin C++ row above is built with _ENABLE_AVX2.
Rust toolchain: rustc 1.95.0, cargo 1.95.0, release profile. The Rust
row uses runtime AVX2 dispatch when available.
External MT means external multi-thread throughput with 28 caller threads.
The C++ benchmark uses one result buffer per caller thread. The Rust
benchmark uses one reusable Detector per worker thread, warms each worker,
then synchronizes the timed loop.
The reported MT time is throughput-normalized average time per image, not
single-request latency.
The C++ benchmark uses OpenCV resize; the Rust benchmark uses the image
crate resize path. The table is intended for performance comparison, not
result-buffer parity or accuracy evaluation.
See rust/README.md for crate usage and rust/docs/rs-performance-optimization-report.md
for the detailed optimization report.
All contributors who contribute at GitHub.com are listed here.
The contributors who were not listed at GitHub.com:
Jia Wu (吴佳)
Dong Xu (徐栋)
Shengyin Wu (伍圣寅)
Acknowledgment
The work was partly supported by the Science Foundation of Shenzhen (Grant No. 20170504160426188).
Citation
The master thesis of Mr. Wei Wu. All details of the algorithm are in the thesis. The thesis can be downloaded at 吴伟硕士毕业论文
@thesis{wu2023thesisyunet,
author = {吴伟},
title = {面向边缘设备的高精度毫秒级人脸检测技术研究},
type = {硕士学位论文},
institution = {南方科技大学},
year = {2023},
}
The paper for the main idea of this repository https://link.springer.com/article/10.1007/s11633-023-1423-y.
@article{wu2023miryunet,
title = {YuNet: A Tiny Millisecond-level Face Detector},
author = {Wu, Wei and Peng, Hanyang and Yu, Shiqi},
journal = {Machine Intelligence Research},
pages = {1--10},
year = {2023},
doi = {10.1007/s11633-023-1423-y},
publisher = {Springer}
}
The survey paper on face detection to evaluate different methods. It can be open-accessed at https://ieeexplore.ieee.org/document/9580485
@article{feng2022face,
author = {Feng, Yuantao and Yu, Shiqi and Peng, Hanyang and Li, Yan-Ran and Zhang, Jianguo},
journal = {IEEE Transactions on Biometrics, Behavior, and Identity Science},
title = {Detect Faces Efficiently: A Survey and Evaluations},
year = {2022},
volume = {4},
number = {1},
pages = {1-18},
doi = {10.1109/TBIOM.2021.3120412}
}
The loss used in training is EIoU, a novel extended IoU. The paper can be open-accessed at https://ieeexplore.ieee.org/document/9429909.
@article{peng2021eiou,
author = {Peng, Hanyang and Yu, Shiqi},
journal = {IEEE Transactions on Image Processing},
title = {A Systematic IoU-Related Method: Beyond Simplified Regression for Better Localization},
year = {2021},
volume = {30},
pages = {5032-5044},
doi = {10.1109/TIP.2021.3077144}
}
Does ShiqiYu/libfacedetection have a project website?
No homepage URL was recorded for ShiqiYu/libfacedetection in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
How many stars does ShiqiYu/libfacedetection have?
ShiqiYu/libfacedetection has 12.8k GitHub stars — refresh the page for the live number, or check github.com/ShiqiYu/libfacedetection. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is ShiqiYu/libfacedetection open source?
TopGit's metadata for ShiqiYu/libfacedetection does not record a license. Most public repositories on GitHub ARE open source, but the exact terms vary — verify by opening the LICENSE file directly.
What is ShiqiYu/libfacedetection?
ShiqiYu/libfacedetection (ShiqiYu/libfacedetection) is a C++ project on GitHub. From the project's own README: An open source library for face detection in images. The face detection speed can reach 1000FPS.
Where do I read more about ShiqiYu/libfacedetection?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/ShiqiYu/libfacedetection is the definitive source.
Read full README in the tab above.
Is libfacedetection worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of libfacedetection.