Reputation: 61
I am looking to create app to authenticate users using facial recognition.
I checked Android provides Biometric prompt to authenticate the user but I am not sure if This API can be used for my use case. Also, if I can use this API, how many facial data can be stored on a phone, where would that data be stored ?
If I can not achieve what I am looking for, through facial recognition, can this be done using fingerprint authentication. If yes, how many fingerprints can be stored on a device ?
Upvotes: 2
Views: 2657
Reputation: 73
you have to use ml model for face authentication for multiple users, probably tflite android.
Upvotes: 0
Reputation: 984
The AndroidX Biometric library handles all form-factors for you (face, iris, fingerprint, etc.). It does it all under the hood so that you, the developer, implement once and your code will run everywhere no matter what biometric sensor an Android device is using. This blog post and this blog post show how to implement the API so that it works with all form factors.
Regarding your question "how many facial data can be stored on a phone," thankfully that's beyond the concern/purview of your app. The framework handles all this for you behind the scene as I have explained here.
Upvotes: 0
Reputation: 1806
This might be a late but I will like to add few note: Quick Question: Why store biometrics data when you can simply allow the device to manage the data it self ? Also, for data authenticity, I am only guessing that if the device handles this datas by it self, then we're kind of sure that the biometric data is at lease authentic because we did not store it somewhere that we might loose it or accidentally manipulate such data and so on...
Which makes me conclude that when a user set their device biometrics, my app will simply use the data to authenticate them when necessary, so if let say the user changed their biometrics data, it will change across my app also, this is my own opinion and approach, I believe it's close to redundancy if my app has to capture the data that the device already have and if the device does not have this data, I will instruct the user via my app to set their biometrics authentications. Note: this might not applied to everyone, it's just what I think is consistent and saver for the app users.
Below is my implementation:
STEP 1 => I add the below code to my Gradle, it's a simple library that helps consume the hardware Biometric API's and make it friendly to use, you can even clone it manually and modify to your taste.
implementation(group: 'com.an.biometric', name: 'biometric-auth', version: '0.1.0', ext: 'aar', classifier: '')
STEP 2 => I Add the permission needed to my Manifest, please don't forget that you might need to explicitly request for Biometric permission depending on the android os version.
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
Finally => Just read the comments in the code below.
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P){
new BiometricManager.BiometricBuilder(MainActivity.this)
.setTitle("Enter your print to access your wallet.")
.setNegativeButtonText("Try pin instead")
.build()
.authenticate(new BiometricCallback() {
@Override
public void onSdkVersionNotSupported() {
Log.e("SDK", "Not supported");
/*
* Will be called if the device sdk version does not support Biometric authentication
*/
}
@Override
public void onBiometricAuthenticationNotSupported() {
Log.e("BIOMETRIC", "Not supported");
/*
* Will be called if the device does not contain any fingerprint sensors
*/
}
@Override
public void onBiometricAuthenticationNotAvailable() {
Log.e("BIOMETRIC", "Authentication Not Available");
/*
* The device does not have any biometrics registered in the device.
*/
}
@Override
public void onBiometricAuthenticationPermissionNotGranted() {
Log.e("BIOMETRIC", "Authentication Permission Not Granted");
/*
* android.permission.USE_BIOMETRIC permission is not granted to the app
*/
}
@Override
public void onBiometricAuthenticationInternalError(String error) {
Log.e("BIOMETRIC", "Authentication Internal Error");
/*
* This method is called if one of the fields such as the title, subtitle,
* description or the negative button text is empty
*/
}
@Override
public void onAuthenticationFailed() {
Log.e("BIOMETRIC", "Authentication Failed");
/*
* When the fingerprint doesn’t match with any of the fingerprints registered on the device,
* then this callback will be triggered.
*/
}
@Override
public void onAuthenticationCancelled() {
Log.e("BIOMETRIC", "Authentication Cancelled");
pinDialog();
/*
* The authentication is cancelled by the user.
*/
}
@Override
public void onAuthenticationSuccessful() {
Log.e("BIOMETRIC", "Authentication Successful");
/*
* When the fingerprint is has been successfully matched with one of the fingerprints
* registered on the device, then this callback will be triggered.
*/
}
@Override
public void onAuthenticationHelp(int helpCode, CharSequence helpString) {
Log.e("BIOMETRIC", "Authentication Help");
/*
* This method is called when a non-fatal error has occurred during the authentication
* process. The callback will be provided with an help code to identify the cause of the
* error, along with a help message.
*/
}
@Override
public void onAuthenticationError(int errorCode, CharSequence errString) {
Log.e("BIOMETRIC", "Authentication Error");
setSelectedTab(0);
/*
* When an unrecoverable error has been encountered and the authentication process has
* completed without success, then this callback will be triggered. The callback is provided
* with an error code to identify the cause of the error, along with the error message.
*/
}
});
}
Almost forget, this implementation is for finger print only not for facial recognition, actually, located this question looking for facial recognition implementation...lol.
Happy Coding.
Upvotes: 0
Reputation: 837
There will be a limit to the number of Face images or Fingerprint Images or Fingerprint Templates you can save on a device with a limited capacity of storage space like an Android device. As of now, your average Android device on the market may not have more than 32 Gb of free storage space.
Facial Images will likely occupy more space than Fingerprint images if you intend to retain them for future use with quality features unlike Fingerprint images which will occupy much lesser storage space in an archive.
Depending on whether you want to save your Facial images or Fingerprint Images as either *.jpg, *.png, *.bmp or any of the other common image formats, the type of image format will also influence the number of Face images or Fingerprint images you will save. For example, *.bmp images may take more space than *.png or *.jpg files.
As for Fingerprint images, you can further process them to Fingerprint Templates from which you can archive their encoded text data. This will not take up much space in your storage space as Fingerprint templates will be use up little space like text based data unlike when you are saving the full Fingerprint Image.
For archiving your Biometric Data captured from your mobile device, if you want more storage space, you would be better of sending your biometric data to a managed cloud server or a remote computer somewhere with sufficient storage space than your mobile device. With most cloud based servers, you can request for more storage space as your application data storage needs scale up. For Physical remote servers you would have to arrange for a harddisk upgrade to one with much bigger data capacity.
You could also make things easier for yourself by writing code for authentication to run on the server side so that your mobile device is purposely used for capturing Face image or Fingerprint image and sending it for archiving and authentication to the remote server and then once the match result ( whether a match found or a match not found) is determined, your Android device receives the match result and reports back to the user of your Android Biometric Authentication App.
You could consider having your Android App call some web services which send data to your remote servers as soon as you capture a Face Image or enroll a Fingerprint Template.
Upvotes: 0