@yidun/livedetect-plugin-cordova

1.0.3 • Public • Published

活体检测

根据提示做出相应动作,SDK 实时采集动态信息,判断用户是否为活体、真人

平台支持(兼容性)

Android iOS
适用版本区间:4.4以上 适用版本区间:9 - 14

环境准备

CocoaPods安装教程

资源引入/集成

cordova plugin add @yidun/livedetect-plugin-cordova

iOS Quirks

  1. 易盾活体检测用到摄像头功能,请确保有摄像和网络权限
  2. If you are developing for iOS 10+ you must also add the following to your config.xml
<config-file platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription" overwrite="true">
  <string>Allow the app to use your camera</string>
</config-file>

<!-- or for Phonegap -->

<gap:config-file platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription" overwrite="true">
  <string>Allow the app to use your camera</string>
</gap:config-file>
  1. 编译: 将引入SDK头文件的.m文件重命名为.mm文件 或者 在Xcode中找到TARGETS-->Build Setting-->Apple Clang - Language-->Compile Source As在这个选项中选择 Objective-C++

  2. ios编译需安装pod环境。配置好开发者账号即可编译

  3. app接入活体设置(如权限设置等)请参考易盾文档

Android Quirks

  1. 易盾活体检测用到摄像头功能,请确保有摄像和网络权限
  2. 预览高度不要随意设置,请遵守大部分相机支持的预览高宽比,3:4或9:16
  3. 如果想在android设置预览的容器形状,请修改preview_layout.xml

SDK方法说明

1.初始化

  var $actionEl = document.getElementById('detectAction');  // 显示动作提示的元素
  var yidunAliveDetector = new YidunAliveDetect({
          x: 100,  // Number, 预览窗口x坐标
          y: 100,  // Number, 预览窗口y坐标
          width: 180,  // Number, 预览窗口宽度
          height: 240, // Number, 预览窗口高度
          radius: 90, // Number, 预览窗口圆角,android无效
          businessId: '从易盾申请的id'
        }, function (ev) {
          // 检测提示
          if (ev['state_tip']) {
            // 用户可以根据action_type自定义提示文案
            $actionEl.innerText = `${YidunAliveDetect.DETECT_ACTION_TYPES[ev['action_type']]}--文案: ${ev['state_tip']}`;
          } else {
            $actionEl.innerText = '';
          }
          
          // 检测结果
          if (ev['is_passed']) {
            // TODO: 处理token, ev['token']
            return;
          }
          
          // 检测失败
          if (ev['error_code']) {
            // TODO: 处理检测失败情况,ev['error_code']
            return;
          }
          
          if (ev['over_time']) {
            // TODO: 处理检测超时
            return;
          }
        });

开始检测

  yidunAliveDetector.startDetect()

停止检测

  yidunAliveDetector.stopDetect()

移除检测

  yidunAliveDetector.removeDetect()

动作类型映射

YidunAliveDetect.DETECT_ACTION_TYPES = {
    '0': '正视前方',
	'1': '向右转头',
	'2': '向左转头',
	'3': '张嘴动作',
	'4': '眨眼动作',
	'5': '动作错误(检测环境过差或者动作不标准)',
	'6': '动作通过'
};

简单示例app

cordova-yidun-alive-detect-demo for a complete working Cordova example for Android and iOS platforms.

Package Sidebar

Install

npm i @yidun/livedetect-plugin-cordova

Weekly Downloads

1

Version

1.0.3

License

Apache 2.0

Unpacked Size

3.19 MB

Total Files

27

Last publish

Collaborators

  • hzzly
  • zhaoxuhui
  • vortesnail
  • gssify
  • yidunfe
  • hcyang
  • liulingfeng
  • luolihao