Detect and Recognize faces as fast as possible in react native!
npm install react-native-facerecognition




x86 CPU Download this package Click herex86_64 CPU Download this package Click herearm64-v8a CPU Download this package Click herereact-native-facerecognition/android/app/src/main/jniLibs and that's all!>ā ļø Since we're focusing our efforts on next updates, we are really welcome for any issues/pulls to improve the way we go.
š„ Checkout our main example to get the right way to start.
~~~
npm install react-native-facerecognition --save
or
yarn add react-native-facerecognition
~~~
>ā ļø We are highly recommend you to use Deamon gradle for building faster and ignore any error may happen.
* Inside build.gradle put this line in projectName/android/build.gradle.
~~~
repositories {
...
google()
}
...
classpath 'com.android.tools.build:gradle:3.0.1'
...
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
...
}
}
~~~
* And go to projectName/android/gradle/wrapper/gradle-wrapper.properties and change this.
~~~
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
~~~
* You would need to link the library once you install it.
~~~
react-native link react-native-facerecognition
~~~
* Add this line into build.gradle and the path projectName/android/app/build.gradle.
~~~
compileSdkVersion 26
buildToolsVersion "26.0.2"
....
....
~~~
* Then put this lines into settings.gradle and the path projectName/android/settings.gradle.
~~~
include ':openCV'
project(':openCV').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-facerecognition/android/openCV')
~~~
* You need to put permissions to use Camera on AndroidManifest.xml and remove the line below.
~~~
...
~~~
* First, put this line into MainApplication.java and its path projectName/android/app/src/main/java/com/projectName/MainApplication.java.
~~~
import opencv.android.FaceModulePackage;
...
return Arrays.
new FaceModulePackage()
);
~~~
* Then add this line into build.gradle and the path projectName/android/app/build.gradle.
~~~
compileSdkVersion 26
buildToolsVersion "26.0.2"
....
....
....
dependencies {
compile project(':react-native-facerecognition')
}
~~~
* Inside settings.gradle put these lines you can find the path at projectName/android/settings.gradle
~~~
include ':react-native-facerecognition'
project(':react-native-facerecognition').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-facerecognition/android/app')
include ':openCV'
project(':openCV').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-facerecognition/android/openCV')
~~~
* You need to put permissions to use Camera on AndroidManifest.xml and remove the line below.
~~~
...
~~~
š„ You're ready to go!
model
* Camera.constants.Model.cascade [DEPRECATED]
* Higher recall & More trained faces
* Camera.constants.Model.landmarks
* Higher accuracy at recognition
* Camera.constants.Model.lbp
* Higher precision & Faster & Less trained faces
cameraType
* Camera.constants.CameraType.front
* Camera.constants.CameraType.back
captureQuality
* Camera.constants.CaptureQuality.low
* Camera.constants.CaptureQuality.medium
* Camera.constants.CaptureQuality.high
aspect
* Camera.constants.Aspect.fit
* Camera.constants.Aspect.fill
* Camera.constants.Aspect.stretch
dataset (default: false)
* train your own images. copy Images to that location at android/app/src/main/assets/dataset inside that folder.
> if you will use this, you need to use lbp model only in order to make it work. Please see the test photo there to know how to rename your photos according to that test photo every photo should be named like that name_number.jpg/png.
distance
~~~
~~~
* Distance between the face and the camera. This is very important to keep recognition always works and to help make the result mainly true (this effects the recognition result grossly).
rotateMode - (Landscape/Portrait)
* Camera.constants.RotateMode.on
* Camera.constants.RotateMode.off
* takePicture()
> Take a picture then process it to detect face inside
* train(Object)
> Train the algorithm with a new detected face
* identify()
> Take a picture then predict whom face belongs to
* clear()
> Clear all previous trained faces
onTrained
* Called after success training
onUntrained
* If training fails this function will be called with the error
onRecognized
You get details about recognized face:
* name The face name
* confidence This number indicates how much the result is true. Usually low number < 100 means a good result depends on the distance you put
onUnrecognized
* If recognition fails this function will be called with the error
>If you're not familiar with OpenCV and face recognition you have to be in safe and use our default arguments as we care about all of the details for you. In case of using your own arguments please note that you may effect the accuracy depends on your settings.
* Recognition default arguments
__Arguments__
- distance = {200}
* Training images count
__Minimum__
- There's no maximum but the average is 3~4 photos per face to guarantee high accuracy
š Updates you can find all previous versions and updates up to date!
MIT