An open source library for face detection in images

libfacedetection

This is an open source library for CNN-based face detection in images. The CNN model has been converted to static variales 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 speedup 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/libfacedetectcnn-example.cpp shows how to use the library.
Examples

How to Compile

  • 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.
Create a folder build
mkdir -p build; cd build; rm -rf *;

Cross build for aarch64

  1. set cross compiler for aarch64 (please refer to aarch64-toolchain.cmake)
  2. set opencv path since the example code depends on opencv
cmake \
    -DENABLE_INT8=ON \
    -DENABLE_NEON=ON \
    -DCMAKE_BUILD_TYPE=RELEASE \
    -DCMAKE_TOOLCHAIN_FILE=../aarch64-toolchain.cmake \
     ..

make

Native build for avx2

cmake \
    -DENABLE_INT8=ON \
    -DENABLE_AVX2=ON \
    -DCMAKE_BUILD_TYPE=RELEASE \
    -DDEMO=ON \
     ..

make

CNN-based Face Detection on Windows

MethodTimeFPSTimeFPS
X64X64X64X64
Single-threadSingle-threadMulti-threadMulti-thread
OpenCV Haar+AdaBoost (640x480)----12.33ms81.1
cnn (CPU, 640x480)64.21ms15.5715.59ms64.16
cnn (CPU, 320x240)15.23ms65.683.99ms250.40
cnn (CPU, 160x120)3.47ms288.080.95ms1052.20
cnn (CPU, 128x96)2.35ms425.950.64ms1562.10
  • OpenCV Haar+AdaBoost runs with minimal face size 48x48
  • Face detection only, and no landmark detection included.
  • Minimal face size ~12x12
  • Intel(R) Core(TM) i7-7700 CPU @ 3.6GHz.

CNN-based Face Detection on ARM Linux (Raspberry Pi 3 B+)

MethodTimeFPSTimeFPS
Single-threadSingle-threadMulti-threadMulti-thread
cnn (CPU, 640x480)512.04ms1.95174.89ms5.72
cnn (CPU, 320x240)123.47ms8.1042.13ms23.74
cnn (CPU, 160x120)27.42ms36.479.75ms102.58
cnn (CPU, 128x96)17.78ms56.246.12ms163.50


  • Face detection only, and no landmark detection included.
  • Minimal face size ~12x12
  • Raspberry Pi 3 B+, Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz

Comments

Popular posts from this blog

Google Open Source it's Google I/O 2019 Android App

Nikita Voloboev - His wonderful world of macOS Applications

Free Tools for Teams and Collaboration For Developers