@ezviz/openplatform-ai-uni
v0.0.1-beta.1
Published
萤石开放平台 AI 组件 uni-app SDK
Keywords
Readme
萤石开放平台 AI 组件 uni-app SDK
安装
npm install @ezviz/openplatform-ai-uni注意:本 SDK 暂仅支持 Vue2 。
编译配置
transpileDependencies 配置
在 uni-app 项目根目录创建 vue.config.js 文件,添加如下配置:
module.exports = {
transpileDependencies: ['@ezviz/openplatform-ai-uni']
}引入 uni-app 工程
以人脸活体检测组件 FaceLiveness 为例
方式1 - 使用 easycom 引入
配置 pages.json 文件,添加 ezopen- 前缀匹配规则
{
...
"easycom": {
"autoscan": true,
"custom": {
"^ezopen-(.*)": "@ezviz/openplatform-ai-uni/src/components/$1/index.vue"
}
},
...
}在业务中使用
<template>
<view class="content">
<ezopen-FaceLiveness token="tk...." @complete="onComplete" />
</view>
</template>
<script>
export default {
methods: {
onComplete(event) {
console.log(event)
}
}
}
</script>
<style>
.content {
width: 100%;
height: 100vh;
}
</style>方式2 - 直接引用组件
<template>
<view class="content">
<FaceLiveness token="tk...." @complete="onComplete" />
</view>
</template>
<script>
import FaceLiveness from '@ezviz/openplatform-ai-uni/src/components/FaceLiveness/index.vue';
export default {
components: {
FaceLiveness
},
methods: {
onComplete(event) {
console.log(event)
}
}
}
</script>
<style>
.content {
width: 100%;
height: 100vh;
}
</style>小程序合法域名
request
- https://open.ys7.com
API 说明
FaceLiveness 人脸活体检测组件
属性
| 属性 | 类型 | 是否必填 | 描述 |
| --- | --- | --- | --- |
| token | String | 是 | 用于请求平台接口的凭证,仅支持tk.开头的小权限 token |
| @complete | (event: FaceLivenessCompleteEvent) => void | 是 | 检测完成回调事件,检测是否通过都会触发,回调返回内容说明详见 FaceLivenessCompleteEvent 事件 |
| host | String | 否 | 访问萤石开放平台接口的域名,默认为https://open.ys7.com,如需修改,需同步更改小程序合法域名 |
事件
FaceLivenessCompleteEvent | 属性 | 类型 | 描述 | | --- | --- | --- | | pass | Boolean | 是否检测通过 | | reasonCode | String | 错误码1 检测成功-1r 图片r:清晰度小于0.3-2r 图片r:瞳距小于30-3r 图片r:人脸左右偏转角大于60-4r 图片r:人脸上下俯仰角大于40-5r 图片r:活体置信度小于0.3-6r 其他未定义错误信息错误码还包含-1g、-1b等,含义与上述相同,最后一位字母代表不同颜色光下的图片| | reason | String | 错误原因,返回上述错误码定义的信息 | | analysisData | Object | 返回 r、g、b 三色光对应的图像及接口响应数据,当图片检测失败时,对应的数据不会返回 | | analysisData.r | Object | 红光图片的数据,同类型数据还有绿光analysisData.g、蓝光analysisData.b | | analysisData.r.imageData | String | 图片的 base64 编码数据 | | analysisData.r.apiRes | Object | 平台检测接口响应数据,详细信息见接口文档 |
检测是否通过的判断逻辑
- 清晰度:不低于0.3
- 瞳距:不低于30
- 左右偏转角:在 [-60°, 60°]
- 上下俯仰角:在 [-40°, 40°]
- 活体置信度阈值:不低于0.3
Release Notes
0.0.1-beta.1
Release Date 2025-07-09
- 提供人脸活体检测组件 FaceLiveness 。
