0.3.4-9 • Published 2 years ago

@wg-npm/face-sdk v0.3.4-9

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

face-sdk

install

$ npm install @wg-npm/fack-sdk

how to use

import FaceSDK from "@wg-npm/face-sdk";
// 定义传入options
const options = {
  //获取签名的函数,需返回Promise对象
  signHandler: () => {
    return Promise.resolve({
      //调用Face Service后端地址
      serviceUrl: "https://www.baidu.com",

      //分配的AppCode
      appCode: "TC",

      //用户编号
      userNo: "userNo",

      //签名
      signature: "signature",

      //时间戳
      timestamp: 1616039507624,
    });
  },
  //需识别的用户名称
  name: "张三",

  //需识别的用户身份证号
  idCard: "614938471839283941",

  //调用方类型:web, mobile
  sourceType: "web",

  //业务类型:LOGIN, COURSE, ONLINE_VIDEO, GENERAL_ACTIVITY
  targetType: "login",

  //在targetType="course"的情况下需传入课程courseCode, 拍照检测必传
  targetCode: "targetCode",

  //在非登录场景下检测时传入学习活动或课程ID,拍照检测必传
  targetCode: "100001",

  //在非登录场景下检测时传入学习活动或课程名称,拍照检测必传
  targetName: "高等数学",

  //可以自定义传入二维码刷新间隔,单位为毫秒
  interval: 3000,

  //用户工号,拍照检测必传
  userNo: "u00001",

  //学习活动类型,拍照检测必传
  activityType: "",

  //音视频观看进度,拍照检测必传
  businessKey: "",

  //  二维码蒙层显示时的回调函数
  onShowMask: (response) => {},

  /*  调用方自定义人脸检测有效方法
      不传入该函数执行默认方法:
      在sourceType="web"且targetType="course"的情况下,展示下次需要识别的时间,并倒计时;倒计时结束唤醒Face-H5二维码蒙层。
      其余情况均在success回调函数中返回人脸检测有效的结果。
      该方法的response同样为人脸检测有效的结果。
   */
  onCheckSuccess: (response) => {},

  /*  调用方自定义人脸检测失效方法
      不传入该函数执行默认方法:
      在sourceType="web"的情况下,唤醒Face-H5二维码蒙层。
      其余情况均在success回调函数中返回人脸检测失效的结果。
      该方法的response同样为人脸检测失效的结果。
   */
  onCheckFail: (response) => {},

  /*  调用方自定义用户扫描二维码识别成功之后的方法
      可以获取到人脸检测成功的返回数据。
   */
  afterCheckSuccess: (response) => {},

  /*  调用成功时执行的回调函数,response如下:
      Result {
        //SDK接口调用成功标识
        success: true, 
        data: {
          //人脸检测是否有效标识
          status: "SUCCESS"
          //距离下次检测时间间隔,单位为毫秒
          times: 5000
          //face-h5调用地址
          url: "http://api.com"
        }, 
        //提示信息
        message: "success"
      }
   */
  success: (response) => {},

  /*  调用失败时执行的回调函数,response如下:
      Result {
        //SDK接口调用失败标识
        success: false, 
        data: {}, 
        //提示信息
        message: "serviceUrl parameter error"
      }
   */
  fail: (response) => {},

  //调用完成时执行的回调函数,无论成功或失败都会执行
  complete: () => {},
};

//人脸识别接口
FaceSDK.startFaceRecognition(options);

//人脸拍照接口
FaceSDK.startFaceCapture(options);

//success,fail,complete方法支持promise方式使用
FaceSDK.startFaceRecognition(options)
  .then((res) => console.log(res))
  .catch((res) => console.log(res))
  .finally(() => console.log("on finally"));
0.3.4-3

2 years ago

0.3.2-5

2 years ago

0.3.4-2

2 years ago

0.3.2-4

2 years ago

0.3.4-5

2 years ago

0.3.2-7

2 years ago

0.3.4-4

2 years ago

0.3.2-6

2 years ago

0.3.4-7

2 years ago

0.3.4-6

2 years ago

0.3.2-8

2 years ago

0.3.4-9

2 years ago

0.3.4-8

2 years ago

0.3.2-1

2 years ago

0.3.4-1

2 years ago

0.3.2-3

2 years ago

0.3.2-2

2 years ago

0.3.0

2 years ago

0.3.2

2 years ago

0.3.3

2 years ago

0.3.3-4

2 years ago

0.3.3-3

2 years ago

0.3.3-6

2 years ago

0.3.3-5

2 years ago

0.3.3-8

2 years ago

0.3.3-7

2 years ago

0.3.3-9

2 years ago

0.3.3-2

2 years ago

0.3.3-1

2 years ago

0.3.1-2

3 years ago

0.2.13

3 years ago

0.3.1-1

3 years ago

0.3.0-16

3 years ago

0.3.0-15

3 years ago

0.3.0-14

3 years ago

0.3.0-18

3 years ago

0.3.0-17

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.7

3 years ago

0.2.8

3 years ago

0.2.6

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago