Cordova Plugin Face Detection - LITE
Plugin for facial detection in real-time and off-line, extremely lite. It is designed to run on old smartphones. This plugin implemented the method described in 2013 by Markuš et al.
PS: For older smartphones, it is ideal that each frame reviewed has a maximum height and width of 60 pixels and the processing cycle runs every 100 milliseconds or more. In the sample project, this was implemented.
Installation
This plugin can be used on the iOS, Android, Electron and Browser platforms;
cordova plugins add cordova-plugin-facedetection-lite
Methods
initFaceDetection(sizeFrameMemory, faceFinderPath, resultCallback)
sizeFrameMemory
- Number of frames that will be used to reinforce the detection of all faces. Defaults to 5faceFinderPath
- Facial training file location, being allowed offline. Defaults to cascades/facefinderresultCallback
- Callback function
Code:
facedetection;
Warning: Until the current version, the parameters are being ignored on some platforms, being ixed default value in the code.
detections(rgba, width, height, minSizeFace, maxSizeFace, iouthreshold, resultCallback)
rgba
- Image in byte arraywidth
- Image widthheight
- Image heightminSizeFace
- Minimum size of selected facesmaxSizeFace
- Minimum size of selected facesiouthreshold
- Maximum size of selected facesresultCallback
- Callback function
Code:
facedetection;
Warning: Until the current version, only the first 3 parameters are implemented and the rest of the parameters are being ignored on some of the platforms, being fixed default value in the code.
Sample App
cordova-sample-facedetection for a complete working Cordova example for Android, iOS and Browser platforms.
iOS / Android |
Browser |
Task List
- Basic structure of the plugin;
- Add PicoJS library to the Browser
- Compile Pico library in C for iOS
- Compile Pico library in C for Android
- Process dynamic path to training file
- Process dynamic parameters when calling each function
Development
If you intend to do some improvement in the project, follow some instructions, such as compiling library in the C language.
Recompiling libraries
If you modify the C source files, be sure to re-build the compiled libraries.
Android
You can re-build the libpicornt.so
binaries using the ndk-build script.
To do so:
- Install Android NDK as instructed here
- Add the NDK install path to your path environment variable
- By default it's installed under $ANDROID_SDK_HOME/ndk-bundle
- e.g.
export PATH=$PATH;$ANDROID_SDK_HOME/ndk-bundle
- Set the ANDROID_NDK_HOME environment variable to your NDK install path
- e.g.
export ANDROID_NDK_HOME=$ANDROID_SDK_HOME/ndk-bundle
- e.g.
- Open terminal in plugin root folder
- Run
./compile-android
(compile-android.cmd
on Windows)
iOS
If you modify the C source code in common/picornt/
you'll need to rebuild the static library and headers in src/ios/libs
.
- Open terminal in plugin root folder
- Run
./compile-ios
Credits
Created by Luís De Marchi @luisdemarchi - Linkedin
Libraries used:
- Mobile (Language C) : nenadmarkus/pico
- Browser (Language JS): tehnokv/picojs