1 Star 1 Fork 0

raspberry-pi-app/LiveFaceReco

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

LiveFaceReco_RaspberryPi

Face recognition and live estimation on Raspberry Pi 4B with average FPS around 20 and 2800+ faces loaded.

Update

2021-07-22: reworked cmakefiles and livefacereco code, added ParallelVideoCapture module and DatasetHandler module. y9luiz

2020-09-05: with the help of konglingzheng, add ncnn lib of nano, please simply change the path in the cmakelist when other platform is used.

2020-08-26: add ncnn libs (ubunutu, arm64-v8a, armeabi-v7a, and RaspberryPi4B ) to include folder

Introduction

The project implements Face Recognition and Face Anti Spoofing on Raspberry pi with the models transformed to ncnn. Besides, the whole project is designed as an entrance guard system by reading face images in the img folder and determining whether the input face is in the dataset by Arcface. The most interesting function is that it is capable to estimate whether the face getting from the camera is real just relaying on the input image instead of with the help of human body sensors or temperature sensors. As a result, it can avoid the situation of deceived by false faces, including printed paper photos, the display screen of electronic products, silicone masks, 3D human images, etc.

Face-Anti-Spoofing


Performance

image

image

image

  • The program was run with 2859 faces in img folder, which is enough for a moderate entrance guard system.

  • There is only one image of me(not wearing a mask) in the database, and it is capable to recognize me when wearing a mask(not robust enough). The performance can be improved when retinaface is used as the Detector(TODO).

  • The average FPS is around 20, and it successfully recognized me from the database.

  • The number in cyan indicates the score for face recognition, and the number in yellow shows the confidence of live estimation.


Dependency

  • OpenCV >= 4.0.0

Preparation

  • OpenCV

    Building OpenCV on Raspberry Pi might be slightly different from that in other linux systems. If you met some problem, you may find this website helpful.

  • project_path:

    set project_path in livefacereco.hpp into your own

  • face database:

    set record_face=true in livefacereco.hpp to add your face to database, you can rename it in img folder.


Run

make sure you have changed project_path to your own

mkdir build
cd build
cmake ..
make -j4
./LiveFaceReco

Adjustable Parameters

  1. largest_face_only: only detects the largest face
  2. record_face: add face to database
  3. distance_threshold: avoid recognize face which is far away (default 90)
  4. face_thre: threshold for Recognition (default 0.40)
  5. true_thre: threshold for Anti Spoofing (default 0.89)
  6. jump: jump some frames to accelerate
  7. input_width: set input width (recommend 320)
  8. input_height: set input height (recommend 240)
  9. output_width: set output width (recommend 320)
  10. output_height: set input height (recommend 240)
  11. project_path: set to your own path

TODO LIST

  • Implement RetinaFace as the detector
  • optimize FPS when output frame is large
  • Network communication to work with IoT devices.

Citation

@inproceedings{deng2018arcface,
title={ArcFace: Additive Angular Margin Loss for Deep Face Recognition},
author={Deng, Jiankang and Guo, Jia and Niannan, Xue and Zafeiriou, Stefanos},
booktitle={CVPR},
year={2019}
}

@inproceedings{deng2019retinaface,
title={RetinaFace: Single-stage Dense Face Localisation in the Wild},
author={Deng, Jiankang and Guo, Jia and Yuxiang, Zhou and Jinke Yu and Irene Kotsia and Zafeiriou, Stefanos},
booktitle={arxiv},
year={2019}
}

@inproceedings{ncnn,
title={ncnn https://github.com/ElegantGod/ncnn},
author={ElegantGod},
}

@inproceedings{Face-Recognition-Cpp,
title={Face-Recognition-Cpp https://github.com/markson14/Face-Recognition-Cpp},
author={markson14},
}

@inproceedings{insightface_ncnn,
title={insightface_ncnn https://github.com/KangKangLoveCat/insightface_ncnn},
author={KangKangLoveCat},
}

@inproceedings{Silent-Face-Anti-Spoofing,
title={Silent-Face-Anti-Spoofing https://github.com/minivision-ai/Silent-Face-Anti-Spoofing},
author={minivision-ai},
}
Tencent is pleased to support the open source community by making ncnn available. Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. If you have downloaded a copy of the ncnn binary from Tencent, please note that the ncnn binary is licensed under the BSD 3-Clause License. If you have downloaded a copy of the ncnn source code from Tencent, please note that ncnn source code is licensed under the BSD 3-Clause License, except for the third-party components listed below which are subject to different license terms. Your integration of ncnn into your own projects may require compliance with the BSD 3-Clause License, as well as the other licenses applicable to the third-party components included within ncnn. A copy of the BSD 3-Clause License is included in this file. Other dependencies and licenses: Open Source Software Licensed Under the zlib License: The below software in this distribution may have been modified by THL A29 Limited (“Tencent Modifications”). All Tencent Modifications are Copyright (C) 2017 THL A29 Limited. ---------------------------------------------------------------------------------------- 1. neon_mathfun.h Copyright (C) 2011 Julien Pommier 2. sse_mathfun.h Copyright (C) 2007 Julien Pommier 3. avx_mathfun.h Copyright (C) 2012 Giovanni Garberoglio Interdisciplinary Laboratory for Computational Science (LISC) Fondazione Bruno Kessler and University of Trento via Sommarive, 18 I-38123 Trento (Italy) Terms of the zlib License: --------------------------------------------------- Copyright (c) <year> <copyright holders> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Open Source Software Licensed Under the BSD 2-Clause License: The below software in this distribution may have been modified by THL A29 Limited (“Tencent Modifications”). All Tencent Modifications are Copyright (C) 2017 THL A29 Limited. ---------------------------------------------------------------------------------------- 1. squeezenet 1.1 Copyright (c) 2016 Forrest N. Iandola and Matthew W. Moskewicz and Khalid Ashraf and Song Han and William J. Dally and Kurt Keutzer All rights reserved. 2. caffe.proto master All contributions by the University of California: Copyright (c) 2014-2017 The Regents of the University of California (Regents) All rights reserved. All other contributions: Copyright (c) 2014-2017, the respective contributors All rights reserved. Terms of the BSD 2-Clause License: -------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Open Source Software Licensed Under the BSD 3-Clause License: The below software in this distribution may have been modified by THL A29 Limited (“Tencent Modifications”). All Tencent Modifications are Copyright (C) 2017 THL A29 Limited. ---------------------------------------------------------------------------------------- 1. android.toolchain.cmake master Copyright (c) 2010-2011, Ethan Rublee Copyright (c) 2011-2014, Andrey Kamaev All rights reserved. Terms of the BSD 3-Clause License: -------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of [copyright holder] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

[树莓派]人脸识别+活体检测 加载2800+人脸数据还能达到20FPS! 展开 收起
README
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/raspberry-pi-app/LiveFaceReco_RaspberryPi.git
git@gitee.com:raspberry-pi-app/LiveFaceReco_RaspberryPi.git
raspberry-pi-app
LiveFaceReco_RaspberryPi
LiveFaceReco
master

搜索帮助