This is an android app that can use an inbuilt camera/video stream via Wifi/Wifi-Direct to recognize people from a pre-enrolled list of persons using Face Recognition. The goal is to be able to run the algorithms locally on the device without accessing API/servers running on the cloud & utilize only a single photo per enrollment.
Please bear in mind that the purpose was to just demonstrate and quickly integrate existing open-source Face APIs as a starter kit for further work. This is by no means an out-of-the-box solution for FR, nor is it a production ready app.
As they often say in CS circles: there's no free lunch.
This is useful for anyone who (like me) has struggled to get existing open-source face recognition stuff to work on multiple android platforms & show basic POCs with subject enrollment, recognition etc.
For face recognition on the devices, the following libraries have been used/integrated:
Download the apk file from here.
This apk file should work for the architectures mentioned below with Android versions >= Marshmellow (API 23+). This is the minimum requirement for facenet.
Note: You will have to allow installation from unknown sources option to install the app. I personally don't see any value is putting it out as a stand-alone app on playstore, as it is not a complete solution. Let me know if you think otherwise, and I'll consider putting it up.
The OpenCV version limits the arch support to the following:
- armeabi
- armeabi-v7a
- mips
- x86
Upgrading to OpenCV 3.0+ gives you flexibility to deploy on most architectures, but the java api for face-recognition still has issues and hence I am sticking with OpenCV 2.4 for now.
Lower-end phones running on ARM Cortex(arm64-v8a) will have to use OpenCV 3.0+
Versions & Reqs to duplicate build:
- Android studio:
3.0.1
- Gradle:
3.0.1
(if you aren't using this version, please upgrade via Android Studio & the project should build without any errors) - OpenCV Android SDK (for NDK Support):
2.4.13.3
Follow these instructions if you do not have OpenCV set up in your local machine.
Update OpenCV_Dir
to reflect the path to your OpenCV Directory in CMakeLists.txt
Verify if these files exist in the project. If not, follow the instructions below to add them.
Face-Recognition-on-Android\app\src\main\assets\facenet_inception.pb
Face-Recognition-on-Android\app\src\main\res\raw\haarcascade_frontalface_default.xml
Face-Recognition-on-Android\app\src\main\res\raw\lbpcascade_frontalface.xml
Model files
-
The pre-trained weights file can be found here. Add the weights file to the assets folder for the facenet method to work.
-
OpenCV Face Tracker requires the cascade files, which are already part of this repository. If you want to test with their other defaults, you can find them here.
-
Facenet on tensorflow-lite - get the converted model here
-
The notebook used to convert the model here
Note: The updated version of the app using tflite is a WIP.
If you are trying to adapt it for your own use case/facing issues with deploying or wish to share your comments/feedback, reach me at div1090@gmail.com