当前位置:网站首页>动作活体检测能力,构建安全可靠的支付级“刷脸”体验
动作活体检测能力,构建安全可靠的支付级“刷脸”体验
2022-07-22 19:32:00 【nginx】

华为机器学习服务的动作活体检测能力,通过采用指令动作配合的方式进行活体检测,在眨眼、张嘴、左摇头、右摇头、注视、点头六种动作中随机选择三种,让用户按指令完成动作,使用人脸关键点及人脸追踪技术,通过连续的图片,计算变化距离与不变距离的比值,进行上一帧图像与下一帧图像的对比,从而验证用户是否为真实活体本人操作,对照片、视频和面具的攻击具有很好的防御效果,是人脸识别能否有效应用的前提条件。
除此之外,在使用动作活体检测能力过程中,针对遮挡和光线不佳等检测场景,支持引导检测,如及时展示“暗光提示”、“人像模糊”“墨镜、口罩遮挡”、“人脸过近、过远”等提示信息,实现更加友好的交互体验,打造安全可靠的支付级活体检测能力。

相较于无需用户做出配合动作的静默活体检测,交互式的动作活体检测能力更适用于银行金融、医疗等需要人机交互的场景。比如,在金融领域使用该技术,用户不必亲去银行场地,远程即可进行金融开户、保险理财等操作;在线下超市等自助支付场景中,用户需通过动作活体检测完成支付,保证个人资金安全性;在社保、医保、个税等办理操作场景中,同样需要通过动作活体检测来精准验证操作人是否为活体本人,以此提高操作安全性。
那么如何集成动作活体检测能力呢?步骤如下。
1开发步骤
在进行开发之前,您需要完成必要的开发准备工作,同时请确保您的工程中已经配置HMS Core SDK的Maven仓地址,并且完成了本服务的SDK集成。
方式一:fullSDK方式集成
方式二:基础SDK方式集成
dependencies{// 引入动作活体检测集合包。implementation 'com.huawei.hms:ml-computer-vision-interactive-livenessdetection: 3.2.0.122'}
动作活体检测提供两种调用方式,您可以根据需求选择相应的调用方式构建活体检测服务。
dependencies{// 引入活体检测plugin包。implementation 'com.huawei.hms:ml-computer-vision-interactive-livenessdetection-plugin:3.2.0.122'}

了解更多详情>>
1.1默认扫描界面1.创建活体检测结果回调,用于获取检测结果。private MLInteractiveLivenessCapture.Callback callback = new MLInteractiveLivenessCapture.Callback() {@Overridepublic void onSuccess(MLInteractiveLivenessCaptureResult result) {// 检测成功的处理逻辑,检测结果可能是活体或者非活体。swich(result.getStateCode()) {case InteractiveLivenessStateCode.ALL_ACTION_CORRECT://验证通过后对应具体操作case InteractiveLivenessStateCode.IN_PROGRESS://正在检测时对应具体操作…}@Overridepublic void onFailure(int errorCode) {// 检测未完成,如相机异常CAMERA_ERROR,添加失败的处理逻辑。}};2.创建活体检测实例,启动检测。MLInteractiveLivenessConfig interactiveLivenessConfig = new MLInteractiveLivenessConfig.Builder().build();MLInteractiveLivenessCaptureConfig captureConfig = new MLInteractiveLivenessCaptureConfig.Builder().setOptions(MLInteractiveLivenessCaptureConfig.DETECT_MASK).setActionConfig(interactiveLivenessConfig).setDetectionTimeOut(TIME_OUT_THRESHOLD).build();MLInteractiveLivenessCapture capture = MLInteractiveLivenessCapture.getInstance();capture.startDetect(activity, callback);1.2自定义扫描界面1.创建MLInteractiveLivenessDetectView,并加载到Activity布局。/*** I.绑定相机预览界面,设置活体识别区域。*在相机预览流中,活体检测会对人脸在不在预览视频流的人脸框中进行判断,为了提高活*体的通过率,建议人脸框放在屏幕中间,且活体识别区域比绘制的人脸框范围略大。* II.设置是否检测口罩。* III.设置结果回调。* IV.将MLInteractiveLivenessDetectView加载到Activity。*/@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_liveness_custom_detection);mPreviewContainer = findViewById(R.id.surface_layout);MLInteractiveLivenessConfig interactiveLivenessConfig = new MLInteractiveLivenessConfig.Builder().build();mlInteractiveLivenessDetectView = new MLInteractiveLivenessDetectView.Builder().setContext(this)//设置是否检测口罩.setOptions(MLInteractiveLivenessCaptureConfig.DETECT_MASK)//设置检测动作,静默为0,动作为1。.setType(1)//设置相机视频流预览位置(左上右下像素值基于预览view).setFrameRect(new Rect(0, 0, 1080, 1440))//设置动作活体调用.setActionConfig(interactiveLivenessConfig)//设置人脸框相对于预览view的位置(左上右下基于640*480图像坐标,建议宽高比符合实际人脸比例),人脸框作用为检测人脸远近和是否偏移.setFaceRect(new Rect(84, 122, 396, 518))//设置检测超时时间,建议10000毫秒左右。.setDetectionTimeOut(10000)//设置结果回调.setDetectCallback(new OnMLInteractiveLivenessDetectCallback() {@Overridepublic void onCompleted(MLInteractiveLivenessCaptureResult result) {// 活体检测完成时的结果回调swich(result.getStateCode()) {case InteractiveLivenessStateCode.ALL_ACTION_CORRECT://验证通过后对应具体操作case InteractiveLivenessStateCode.IN_PROGRESS://正在检测时对应具体操作…}}@Overridepublic void onError(int error) {// 活体检测发生错误时的错误码回调}}).build();mPreviewContainer.addView(mlInteractiveLivenessDetectView);mlInteractiveLivenessDetectView.onCreate(savedInstanceState);}2.对MLInteractiveLivenessDetectView设置生命流程监听。@Overrideprotected void onDestroy() {super.onDestroy();MLInteractiveLivenessDetectView.onDestroy();}@Overrideprotected void onPause() {super.onPause();MLInteractiveLivenessDetectView.onPause();}@Overrideprotected void onResume() {super.onResume();MLInteractiveLivenessDetectView.onResume();}@Overrideprotected void onStart() {super.onStart();MLInteractiveLivenessDetectView.onStart();}@Overrideprotected void onStop() {super.onStop();MLInteractiveLivenessDetectView.onStop();}
访问机器学习服务官网
访问华为开发者联盟官网
获取开发指导文档
华为移动服务开源仓库地址:GitHub、Gitee
关注我们,第一时间了解 HMS Core 最新技术资讯~
边栏推荐
- 为什么我的百度账号登不上去了?百度账号无法登录现象的解决方法介绍
- 网上邻居右键属性打不开怎么办 网上邻居右键属性打不开的解决方法
- Flink data source disassembly and analysis (Wikipedia editssource)
- Interviewer: how to solve the problem of a large number of requests for data that does not exist in redis, which affects the database?
- Why does TCP establish a connection protocol with three handshakes, but close the connection with four handshakes?
- 面试官:大量请求 Redis 不存在的数据,从而影响数据库,该如何解决?
- There is no shortcut in life. Focusing on doing one thing well is the shortcut -- after reading meta wisdom
- Kotlin学习快速入门(8)—— 委托
- Electromagnetic field and electromagnetic wave experiment 4. Be familiar with the application of CST Studio Software in the electromagnetic field
- Gb28181 summary of common problems in the use and secondary development of livegbs streaming media service
猜你喜欢

AWS使用EC2降低DeepRacer的训练成本DeepRacer-for-cloud的实践操作
![[matlab project practice] analysis of spatial and temporal characteristics of drought in a region based on SPI index](/img/a6/33442ad5301c799ba4e5491d818d67.png)
[matlab project practice] analysis of spatial and temporal characteristics of drought in a region based on SPI index

TCP waves four times

Gom引擎Key.lic配套的X-FKGOM授权启动

HMS Core Discovery第16期直播预告|与虎墩一起,玩转AI新“声”态

Apifox learning record

Electromagnetic field and electromagnetic wave experiment 4. Be familiar with the application of CST Studio Software in the electromagnetic field

Flink data source disassembly and analysis (Wikipedia editssource)

CV target detection model sketch (1)

Jupyternotebook runs to the specified line
随机推荐
小马激活工具出现Cannot open file k:\OEMSF 的解决方法
关注公众号免费领取小米移动电源是真的吗?微信朋友圈送小米移动电源
STL container -list Simulation Implementation (three kinds of reverse iterators)
Kali tools sqlmap common usage
Mktdt03 of Shanghai stock exchange quotation document analysis
MySQL --- 子查询 - 子查询概念、规范、分类
电脑待机要按什么键解除 解除电脑睡眠模式的步骤
电脑分区时出现'磁盘上没有足够的空间完成此操作'的解决办法
Sharepreference principle + practical analysis
华为昇腾比赛资料
How to embed the monitoring image into wechat official account for live broadcast
小米活期宝和余额宝哪个好?小米活期宝与阿里余额宝区别详细对比介绍
Mycms we media mall v3.5 release, new free plug-ins
Flink数据源拆解分析(WikipediaEditsSource)
mysql约束之_外键约束 foreign key
常用正则表达式最强整理速查手册(荣耀典藏版)
GB28181流媒体服务LiveGBS使用和二次开发中常见问题总结
Livegbs camera web page low delay plug-in free live broadcast implementation
STL container - vector simulation implementation
12306史上最奇葩验证码:正常用户可轻松识别 抢票软件被拒之门外