当前位置:网站首页>How to realize face verification quickly and accurately?
How to realize face verification quickly and accurately?
2022-06-09 17:31:00 【Huawei mobile services】
Today, with the rapid development of the Internet , Various App The verification method is more and more convenient for users , Enter the password from the beginning , To the fingerprint unlock later , Evolved into today's face brush certification . Brush your face , You can unlock the device 、 On-line / Offline payment 、 Access control 、 Fast ticket check, etc . At the same time, there are many security problems , The first is how to judge the authenticity of users .
HMS Core Machine learning services (ML Kit) The ability of face comparison and living body detection can quickly capture faces , By recognizing and extracting the face features in the template , It can be judged to be a real face without the cooperation of the user , Or face attack , At the same time, the template portrait and face are compared with high accuracy , Output similarity value , Then judge whether they are the same person .
Based on this , Developers can quickly build face detection capabilities , For example, in Finance App in , Compare the user ID photo with the face detection result , Judge the authenticity of user information , It can provide a fast and secure identity verification process , It is applicable to Internet remote account opening 、 Face brushing payment and other financial services . In the office App in , Can take face brush attendance , Identify whether it is me , Effectively prevent punching cards and other behaviors .
Effect display

From the effect display picture , In vivo detection can be completed in a few seconds to accurately identify the fake photos on the mobile phone .
Development steps
The development of preparation
stay AppGallery Connect Configuration information in , The specific development preparation can Reference documents .
To configure HMS Core SDK Of Maven Warehouse address .
open Android Studio Project level “build.gradle” file .

add to AppGallery Connect Plugins and Maven The code base .
stay “allprojects”>“repositories” It's equipped with HMS Core SDK Of Maven Warehouse address .
allprojects {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
}stay “buildscript”>“repositories” It's equipped with HMS Core SDK Of Maven Warehouse address .
buildscript {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
}stay “buildscript”>“dependencies” Add in AppGallery Connect The plug-in configuration .
buildscript{
dependencies {
classpath 'com.huawei.agconnect:agcp:1.3.1.300'
}
}Face comparison function development
- Create a face comparison detector instance .
MLFaceVerificationAnalyzer analyzer = MLFaceVerificationAnalyzerFactory.getInstance().getFaceVerificationAnalyzer();- adopt android.graphics.Bitmap establish MLFrame Object is used to set the template image , Supported image formats include :JPG、JPEG、PNG、BMP.
// adopt bitmap establish MLFrame
MLFrame templateFrame = MLFrame.fromBitmap(bitmap);- Set face comparison template image . If there is no face in the template , It means that the template setting failed , Keep the last set template of this instance unchanged .
List<MLFaceTemplateResult> results = analyzer.setTemplateFace(templateFrame);
for (int i = 0; i < results.size(); i++) {
// Process template image recognition results
}- adopt android.graphics.Bitmap establish MLFrame Object is used to set the comparison picture . Supported image formats include :JPG、JPEG、PNG、BMP.
// adopt bitmap establish MLFrame
MLFrame compareFrame = MLFrame.fromBitmap(bitmap);- Call synchronous or asynchronous methods for face comparison . The detection results mainly include the face information detected in the comparison picture 、 The confidence that the detected face information is the same as the template face . For more information, see MLFaceVerificationResult.
• Asynchronous method sample code :
Task<List<MLFaceVerificationResult>> task = analyzer.asyncAnalyseFrame(compareFrame);
task.addOnSuccessListener(new OnSuccessListener<List<MLFaceVerificationResult>>() {
@Override
public void onSuccess(List<MLFaceVerificationResult> results) {
// Test successful
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
// Detection failed
}
});• Synchronization method sample code :
SparseArray<MLFaceVerificationResult> results = analyzer.analyseFrame(compareFrame);
for (int i = 0; i < results.size(); i++) {
// Test result processing
}- Test complete , Stop the analyzer , Release detection resources .
if (analyzer != null) {
analyzer.stop();
}In vivo detection function development
Default scanning interface
- Create a silent vivisection result callback , Used to obtain test results .
private MLLivenessCapture.Callback callback = new MLLivenessCapture.Callback() {
@Override
public void onSuccess(MLLivenessCaptureResult result) {
// Detect successful processing logic , The test results may be living or non living .
}
@Override
public void onFailure(int errorCode) {
// The test is not complete , If the camera is abnormal CAMERA_ERROR, Add failed processing logic .
}
};- Create a silent vivisection instance , Start detection .
MLLivenessCapture capture = MLLivenessCapture.getInstance();
capture.startDetect(activity, callback);Learn more >>
visit Official website of Huawei developer Alliance
obtain Development guidance document
Huawei mobile service open source warehouse address :GitHub、Gitee
Pay attention to our , The first time to understand HMS Core Latest technical information ~
边栏推荐
- How to ensure personal and property safety when traveling
- 常用数的集合
- 头部物联网SaaS公司G7、E6合并,能否成为to B领域的“美团”?
- Leetcode 1979. Find the greatest common divisor of the array
- iis怎么打开md文件(is无法打开md文件报错怎么解决)
- pyepics数组 -- 4
- nlp网络中两种残差结构对网络的影响
- Virtual storage mechanism
- 从2022年的这几篇论文看推荐系统序列建模的趋势
- Running the code, I want to add a progress bar to see the running progress of the following code in real time. How can I break it?
猜你喜欢

大数据生态安全框架的实现原理与最佳实践(上篇)

刷脸认证如何实现人脸又快又准完成校验?

I/o flow

为什么 SQL 语句使用了索引,但却还是慢查询?

Influence of two residual structures on NLP networks

Running the code, I want to add a progress bar to see the running progress of the following code in real time. How can I break it?

音频 3A 处理实践,让你的应用更「动听」

一些有趣的B+树优化实验

外出旅行如何确保人身及财产安全

A high-value open source knowledge management tool
随机推荐
How to ensure personal and property safety when traveling
【GAMES101】作业1--MVP(模型、视图、投影)变换
Leetcode 1967. 作为子字符串出现在单词中的字符串数目
Leetcode 1979. Find the greatest common divisor of the array
Word 教程,如何在 Word 中更改行距?
Leetcode 1967. The number of strings that appear in a word as substrings
Android 缓存机制 LRUCache
经常弹出:VSCode尝试在目标目录创建文件时发生一个错误 重试 跳过这个文件 关闭安装程序
一款高颜值开源知识管理工具
JLINK RTT can be opened but cannot display problems and bin file output considerations on the desktop
原码、反码、补码、移码 终于搞懂了
通达信开户怎么样?开户安全吗?
关联数组&正则表达式
Oracle一些DDL操作
pyepics Device:PVs的集合
Oracle分页
Key ideas of enterprise service end defense
解决Chrome提示:“您的连接不是私密连接“,且无继续访问选项问题
大数据生态安全框架的实现原理与最佳实践(上篇)
二战陷入这4点误区,再来一年也白搭!