我正在寻找创建应用程序来使用面部识别对用户进行身份验证。
我检查了 Android 提供生物识别提示来验证用户身份,但我不确定此 API 是否可用于我的用例。另外,如果我可以使用这个 API,手机上可以存储多少面部数据,这些数据将存储在哪里?
如果我无法通过面部识别实现我正在寻找的东西,是否可以使用指纹认证来完成。如果是,一个设备上可以存储多少个指纹?
我正在寻找创建应用程序来使用面部识别对用户进行身份验证。
我检查了 Android 提供生物识别提示来验证用户身份,但我不确定此 API 是否可用于我的用例。另外,如果我可以使用这个 API,手机上可以存储多少面部数据,这些数据将存储在哪里?
如果我无法通过面部识别实现我正在寻找的东西,是否可以使用指纹认证来完成。如果是,一个设备上可以存储多少个指纹?
您必须使用 ml 模型对多个用户进行面部身份验证,可能是 tflite android。
您可以在存储空间有限的设备(如 Android 设备)上保存的人脸图像或指纹图像或指纹模板的数量将受到限制。截至目前,您在市场上的平均 Android 设备可能没有超过 32 Gb 的可用存储空间。
如果您打算保留面部图像以供将来使用质量功能,则面部图像可能会比指纹图像占用更多空间,而指纹图像在存档中占用的存储空间要少得多。
取决于您是否要将面部图像或指纹图像保存为 *. .jpg , *. , * . bmp或任何其他常见图像格式,图像格式的类型也会影响您将保存的人脸图像或指纹图像的数量。例如, *。bmp图像可能比 *. png或 *. jpg文件。
至于指纹图像,您可以将它们进一步处理为指纹模板,您可以从中存档其编码的文本数据。这不会在您的存储空间中占用太多空间,因为指纹模板将占用很少的空间,例如基于文本的数据,这与保存完整指纹图像时不同。
为了归档从您的移动设备捕获的生物特征数据,如果您想要更多的存储空间,您最好将生物特征数据发送到托管云服务器或远程计算机,该位置比您的移动设备具有足够的存储空间。对于大多数基于云的服务器,您可以在应用程序数据存储需求扩大时请求更多存储空间。对于物理远程服务器,您必须安排将硬盘升级到具有更大数据容量的服务器。
您还可以通过编写在服务器端运行的身份验证代码来简化自己的工作,以便您的移动设备专门用于捕获面部图像或指纹图像并将其发送到远程服务器进行存档和身份验证,然后在匹配时结果(找到匹配或未找到匹配)确定后,您的 Android 设备会收到匹配结果并报告给您的Android Biometric Authentication App的用户。
您可以考虑让您的 Android 应用程序调用一些 Web 服务,这些服务会在您捕获人脸图像或注册指纹模板后立即将数据发送到您的远程服务器。
这可能已经晚了,但我想补充几点:快速问题:当您可以简单地允许设备自行管理数据时,为什么要存储生物识别数据?另外,对于数据的真实性,我只是猜测如果设备自己处理这些数据,那么我们可以确定生物特征数据至少是真实的,因为我们没有将它存储在我们可能丢失或意外的地方操纵这样的数据等等......
这让我得出结论,当用户设置他们的设备生物特征时,我的应用程序将在必要时简单地使用数据对其进行身份验证,所以如果说用户更改了他们的生物特征数据,它也会在我的应用程序中发生变化,这是我自己的观点和方法,我相信如果我的应用程序必须捕获设备已经拥有的数据并且如果设备没有这些数据,我将通过我的应用程序指示用户设置他们的生物识别身份验证。注意:这可能并不适用于所有人,这只是我认为对应用程序用户来说是一致和节省的。
下面是我的实现:
第 1 步 => 我将以下代码添加到我的 Gradle,它是一个简单的库,有助于使用硬件生物识别 API 并使其易于使用,您甚至可以手动克隆它并根据自己的喜好进行修改。
implementation(group: 'com.an.biometric', name: 'biometric-auth', version: '0.1.0', ext: 'aar', classifier: '')
第 2 步 =>我将所需的权限添加到我的清单中,请不要忘记,您可能需要根据 android 操作系统版本明确请求生物识别权限。
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
最后 =>只需阅读下面代码中的注释即可。
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.
*/
}
});
}
差点忘了,这个实现只用于指纹而不是用于面部识别,实际上,找到这个问题正在寻找面部识别实现......哈哈。
快乐编码。