Giter Site home page Giter Site logo

dmdaguan / libfacedetection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shiqiyu/libfacedetection

0.0 0.0 0.0 62.51 MB

深大教授开源的人脸检测库An open source library for face detection in images. The face detection speed can reach 1500FPS.

License: Other

CMake 0.02% C++ 99.96% Objective-C 0.02% Objective-C++ 0.01%

libfacedetection's Introduction

libfacedetection

深圳大学计算机科学与软件工程学院的于仕琪教授开源了的人脸检测库,人脸检测速度最快可达1500+ FPS! 这是一个用于图像中基于CNN的人脸检测的开源库。CNN模型已转换为C源文件中的静态变量。源代码不依赖于任何其他库。你需要的只是一个C ++编译器。您可以使用C ++编译器在Windows,Linux,ARM和任何平台下编译源代码。 SIMD指令用于加速检测。如果使用Intel CPU或NEON for ARM,则可以启用AVX2。模型文件也已在./models/目录中提供。 examples / libfacedetectcnn-example.cpp显示了如何使用该库。 如何编译: 在使用g++编译源代码时,请添加-O3以启用优化。 使用Microsoft Visual Studio编译源代码时,请选择“最大化速度/ -O2”。

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/libfacedetectcnn-example.cpp shows how to use the library.

Examples

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 support C/C++.

Some tips:

  • 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.
  • ENABLE_INT8=ON is recommended for ARM, but it is not recommended for Intel CPU since it cannot gain better speed sometime even worse.
  • The source code can only run in single thread. If you want to run parally, you can call the face detection function in multiple threads. Yes, multiple-thread is complex in programming.
  • If you want to achieve best performance, you can run the model (not the source code) using OpenVINO on Intel CPU or Tengine on ARM CPU.

If you want to compile and run the example, you can create a build folder first, then run the command:

mkdir 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_AVX2=ON \
    -DCMAKE_BUILD_TYPE=RELEASE \
    -DDEMO=ON \
     ..

make

CNN-based Face Detection on Windows

Method Time FPS Time FPS
X64 X64 X64 X64
Single-thread Single-thread Multi-thread Multi-thread
OpenCV Haar+AdaBoost (640x480) -- -- 12.33ms 81.1
cnn (CPU, 640x480) 64.21ms 15.57 15.59ms 64.16
cnn (CPU, 320x240) 15.23ms 65.68 3.99ms 250.40
cnn (CPU, 160x120) 3.47ms 288.08 0.95ms 1052.20
cnn (CPU, 128x96) 2.35ms 425.95 0.64ms 1562.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+)

Method Time FPS Time FPS
Single-thread Single-thread Multi-thread Multi-thread
cnn (CPU, 640x480) 512.04ms 1.95 174.89ms 5.72
cnn (CPU, 320x240) 123.47ms 8.10 42.13ms 23.74
cnn (CPU, 160x120) 27.42ms 36.47 9.75ms 102.58
cnn (CPU, 128x96) 17.78ms 56.24 6.12ms 163.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

Author

Contributors

  • Jia Wu
  • Shengyin Wu
  • Dong Xu

Acknowledgment

The work is partly supported by the Science Foundation of Shenzhen (Grant No. JCYJ20150324141711699 and 20170504160426188).

libfacedetection's People

Contributors

shiqiyu avatar arun179 avatar nemequ avatar mistralol avatar jubalh avatar solan8 avatar mygityf avatar dmdaguan avatar monomagentaeggroll avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.