Browse by type
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 file has also been provided in directory ./models/.
examples/detect-image.cpp and examples/detect-camera.cpp show how to use the library.
The library was trained by libfacedetection.train.

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:
You can also compile the source code to a static or dynamic library, and then use it in your project.
| Method | Time | FPS | Time | FPS |
|---|---|---|---|---|
| X64 | X64 | X64 | X64 | |
| Single-thread | Single-thread | Multi-thread | Multi-thread | |
| cnn (CPU, 640x480) | 58.06ms. | 17.22 | 12.93ms | 77.34 |
| cnn (CPU, 320x240) | 13.77ms | 72.60 | 3.19ms | 313.14 |
| cnn (CPU, 160x120) | 3.26ms | 306.81 | 0.77ms | 1293.99 |
| cnn (CPU, 128x96) | 1.41ms | 711.69 | 0.49ms | 2027.74 |
| Method | Time | FPS | Time | FPS |
|---|---|---|---|---|
| Single-thread | Single-thread | Multi-thread | Multi-thread | |
| cnn (CPU, 640x480) | 492.99ms | 2.03 | 149.66ms | 6.68 |
| cnn (CPU, 320x240) | 116.43ms | 8.59 | 34.19ms | 29.25 |
| cnn (CPU, 160x120) | 27.91ms | 35.83 | 8.43ms | 118.64 |
| cnn (CPU, 128x96) | 17.94ms | 55.74 | 5.24ms | 190.82 |
Run on default settings: scales=[1.], confidence_threshold=0.3, floating point:
AP_easy=0.856, AP_medium=0.842, AP_hard=0.727
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 (伍圣寅)
The work was partly supported by the Science Foundation of Shenzhen (Grant No. 20170504160426188).
The loss used in model training is EIoU, a novel extended IoU. More details can be found in:
@article{facedetect-yu,
author={Yuantao Feng and Shiqi Yu and Hanyang Peng and Yan-ran Li and Jianguo Zhang}
title={Detect Faces Efficiently: A Survey and Evaluations},
journal={IEEE Transactions on Biometrics, Behavior, and Identity Science},
year={to appear}
}
@article{eiou,
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}
}
https://ieeexplore.ieee.org/document/9429909
$ claude mcp add libfacedetection \
-- python -m otcore.mcp_server <graph>