更新记录

1.0.0(2026-01-13)

  • 新版发布uts插件支持iOS、Android

平台兼容性

uni-app(4.75)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙
× × ×
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 快应用-华为 快应用-联盟
× × × × × × × × × × ×

uni-app x(4.75)

Chrome Safari Android iOS 鸿蒙 微信小程序
× × × ×

yt-bdface-collection

百度离线采集已停止申请新的lincense,但新版本的人脸实名认证的lincense也可以用。可以申请新版的人脸实名认证,从人脸实名认证申请应用,再下载案例到本地从案例中找到对应的授权文件和licnese_key

特别提醒

  • 购买本插件前,请先试用,请先试用,请先试用,确认满足需求之后再行购买。虚拟物品一旦购买之后无法退款。
  • 一定要使用正式版的License文件,不要使用测试版的License,否则造成不可逆的后果自行负责;
  • 百度离线采集已停止申请新的lincense,但新版本的人脸实名认证的lincense也可以用。可以申请新版的人脸实名认证,从人脸实名认证申请应用并下载案例从案例中找到对应授权文件和licnese_key
  • 如有使用上的疑问、bug,可以进交流群联系作者;
  • 请在合法范围内使用,若使用本插件做非法开发,本方概不负责;
  • 可扫描右侧二维码安装Android示例demo,体验插件功能
  • iOS使用示例demo测试时,要先修改manifest中项目名称后再打包(名称长度尽量短一点),不然会因为名称过长,导致App启动不了。

推荐

  1. 结合OCR文字识别插件,识别身份证信息,可以轻松实现实名认证身份核验,插件地址:https://ext.dcloud.net.cn/plugin?id=16105

插件接入

1.点击插件首页”试用“,选择项目导入插件,导入后可在项目根目录下uni_modules文件中查看是否有yt-bdface-collection文件夹,有则导入成功。

Android配置授权文件:将人脸实名认证的授权文件放入uni_modules/yt-bdface-collection/utssdk/app-android/assets文件夹中名称为idl-license.face-android iOS配置授权文件:将人脸实名认证的授权文件放入uni_modules/yt-bdface-collection/utssdk/app-ios/Resources文件夹中名称为idl-license.face-ios

引入插件--注意需引用插件后再打自定义基座调试

在需要使用的页面引入插件

import * as BDFace from '../../uni_modules/yt-bdface-collection';

活体检测/人脸采集

collecFace() {
                let licenseID = "yt-bdy-test-face-android";//换成自己的Android端授权ID

                if (uni.getSystemInfoSync().platform == "ios") {
                    licenseID = "yt-bdy-test-face-ios";//换成自己的iOS端授权ID
                }
                console.log(`licenseID = ${licenseID}`)
                BDFace.authentication({
                    licenseID: licenseID,
                    noActionAcquisition: this.noActionAcquisition,
                    actions: ["Eye", "Mouth", "HeadRight", "HeadLeft"],
                    isRandom: true, //采集动作随机 默认按顺序--noActionAcquisition=true无效
                    qualityLevel: 0, //质量等级  0、默认  1、宽松  2、严格
                    timeOut: 15, //单个动作采集时间 --noActionAcquisition=true无效
                    camera: "front", //摄像头 front back 默认前置
                    isSound: true, //语音 
                    isEnableSound: true, //进入采集页面语音播报是否打开(默认不打开 isSound==true有效)
                    tipsTextColor: "#6450a4", //提示文字色值
                    tipSubTextColor: "#ff00ff", //副标题提示语
                    progressBackgroundColor: "#666666", //刻度线背景色
                    progressScaleColor: "#0000ff", //刻度线背色
                    backgroundColor: "#FFFFFF", //背景色
                    bottomCopyright: "这是uts百度离线采集插件", //底部版权文案
                    copyrightColor: "#00ff00", //版权文字色值
                    showBottomImage: true, //显示底部logo图
                    returnResultImage: true, //返回采集图片,默认返回
                    switchCamera: true, //是否可切换摄像头 右上角多个切换摄像头按钮
                    callBack: (res) => {
                        if (res.code == "200") { //鉴权成功

                        } else if (res.code == "201") { //采集成功
                            this.cropImagePath = `${res.originalCropImagePath}`;
                            this.originalImagePath = `${res.originalImagePath}`;
                        } else if (res.code == "100") { //licenseID为空

                        } else if (res.code == "101") { //没有相机权限,请前往设置打开

                        } else {
                            //其他鉴权错误
                        }
                        console.log(res.message)
                    }
                });
            },
  • 参数说明
参数 类型 说明
licenseID String 授权ID必传
actions array 动作组(默认["Eye","Mouth","HeadUp"])
isRandom bool 采集动作随机 默认(false)不随机
qualityLevel int 采集等级(0:默认1:宽松2:严格)默认0
timeOut int 采集超时
camera String 前后摄像头 front back默认:"front"
isSound bool 是否显示右上角喇叭 默认:true
isEnableSound bool 进入采集页面是否默认开启语音播报(默认false,isSound=true有效)
tipsTextColor String 提示文字色值
tipSubTextColor String 副标题提示文字色值
progressBackgroundColor String 刻度线背景色
progressScaleColor String 选中刻度线色值
backgroundColor String 背景色
bottomCopyright String 底部版权
copyrightColor String 版权色值
showBottomImage true 是否底部logo
switchCamera true 是否可切换摄像头 右上角多个切换摄像头按钮
  • 动作组说明
参数 说明
Eye 眨眨眼
Mouth 张张嘴
HeadLeft 向左缓慢转头
HeadRight 向右缓慢转头
HeadUp 缓慢抬头
HeadDown 缓慢低头
  • 回调说明
状态码 说明
res.code == 100 LicenseID为空
res.code == 200 鉴权成功
res.code == 201 采集成功并返回原图与抠图路径(res.originalImagePath、res.originalCropImagePath)

清除缓存图片

BDFace.clearFileWithPath({
                    path: this.originalImagePath,//图片路径
                    clearCallBack: (res) => {
                        uni.showToast({
                            title: res ? "删除成功" : "删除失败",
                            icon: 'none'
                        })
                    }
                })

更多好用实惠插件

uniapp完整示例

<template>
    <view>
        <view style="display: flex;flex-direction: row; justify-content: space-around;">
            <view class="item">
                <image class="logo" :src="cropImagePath"></image>
                <text class="title" @click="removeCropImage">删除抠图</text>
            </view>
            <view class="item">
                <image class="logo" :src="originalImagePath"></image>
                <text class="title" @click="removeOriginalImage">删除原图</text>
            </view>
        </view>
        <view
            style="display: flex;align-items: center;justify-content: center;background-color: antiquewhite;height: 80rpx;width: 600rpx;margin: 90rpx auto;"
            @click="collecFace">
            <text class="title">{{title}}</text>
        </view>
    </view>
</template>

<script>
    import * as BDFace from '../../uni_modules/yt-bdface-collection';
    export default {
        data() {
            return {
                title: '采集人脸/活体检测',
                noActionAcquisition: false,
                cropImagePath: "/static/logo.png", //抠图
                originalImagePath: '/static/logo.png' //原图
            }
        },
        onLoad() {

        },
        methods: {
            collecFace() {
                let licenseID = "yt-bdy-test-face-android";//换成自己的Android授权ID

                if (uni.getSystemInfoSync().platform == "ios") {
                    licenseID = "yt-bdy-test-face-ios";//换成自己的iOS授权ID
                }
                console.log(`licenseID = ${licenseID}`)
                BDFace.authentication({
                    licenseID: licenseID,
                    noActionAcquisition: this.noActionAcquisition,
                    actions: ["Eye", "Mouth", "HeadRight", "HeadLeft"],
                    isRandom: true, //采集动作随机 默认按顺序--noActionAcquisition=true无效
                    qualityLevel: 0, //质量等级  0、默认  1、宽松  2、严格
                    timeOut: 15, //单个动作采集时间 --noActionAcquisition=true无效
                    camera: "front", //摄像头 front back 默认前置
                    isSound: true, //语音 
                    isEnableSound: true, //进入采集页面语音播报是否打开(默认不打开 isSound==true有效)
                    tipsTextColor: "#6450a4", //提示文字色值
                    tipSubTextColor: "#ff00ff", //副标题提示语
                    progressBackgroundColor: "#666666", //刻度线背景色
                    progressScaleColor: "#0000ff", //刻度线背色
                    backgroundColor: "#FFFFFF", //背景色
                    bottomCopyright: "这是uts百度离线采集插件", //底部版权文案
                    copyrightColor: "#00ff00", //版权文字色值
                    showBottomImage: true, //显示底部logo图
                    returnResultImage: true, //返回采集图片,默认返回
                    switchCamera: true, //是否可切换摄像头 右上角多个切换摄像头按钮
                    callBack: (res) => {
                        if (res.code == "200") { //鉴权成功

                        } else if (res.code == "201") { //采集成功
                            this.cropImagePath = `${res.originalCropImagePath}`;
                            this.originalImagePath = `${res.originalImagePath}`;
                        } else if (res.code == "100") { //licenseID为空

                        } else if (res.code == "101") { //没有相机权限,请前往设置打开

                        } else {
                            //其他鉴权错误
                        }
                        console.log(res.message)
                    }
                });
            },
            //删除原图
            removeOriginalImage() {
                BDFace.clearFileWithPath({
                    path: this.originalImagePath,
                    clearCallBack: (res) => {
                        uni.showToast({
                            title: res ? "删除成功" : "删除失败",
                            icon: 'none'
                        })
                    }
                })
            },
            //删除抠图
            removeCropImage() {
                BDFace.clearFileWithPath({
                    path: this.cropImagePath,
                    clearCallBack: (res) => {
                        uni.showToast({
                            title: res ? "删除成功" : "删除失败",
                            icon: 'none'
                        })
                    }
                })
            }
        }
    }
</script>

<style>
    .content {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .logo {
        height: 200rpx;
        width: 200rpx;
        margin-top: 200rpx;
        margin-left: auto;
        margin-right: auto;
        margin-bottom: 50rpx;
    }

    .text-area {
        display: flex;
        justify-content: center;
    }

    .title {
        font-size: 36rpx;
        color: #8f8f94;
    }

    .item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
</style>

uniapp-x完整示例

<template>
    <view>
        <view style="display: flex;flex-direction: row;">
            <view class="item">
                <image class="logo" :src="cropImagePath"></image>
                <text class="title" @click="removeCropImage">删除抠图</text>
            </view>
            <view class="item">
                <image class="logo" :src="originalImagePath"></image>
                <text class="title" @click="removeOriginalImage">删除原图</text>
            </view>
        </view>
        <view
            style="display: flex;align-items: center;justify-content: center;background-color: antiquewhite;height: 80rpx;width: 600rpx;margin: 40rpx auto;"
            @click="collecFace">
            <text class="title">{{title}}</text>
        </view>
    </view>
</template>

<script>
    import *as BDFace from '@/uni_modules/yt-bdface-collection'
    export default {
        data() {
            return {
                title: '采集人脸/活体检测',
                noActionAcquisition: false,
                cropImagePath: "/static/logo.png",//抠图
                originalImagePath: '/static/logo.png'//原图
            }
        },
        onLoad() {

        },
        methods: {
            collecFace() {
                let licenseID = "yt-bdy-test-face-android";//换成自己的授权ID
                // #ifdef APP-IOS
                licenseID = "yt-bdy-test-face-ios";//换成自己的授权ID
                // #endif
                BDFace.authentication({
                    licenseID: licenseID,
                    noActionAcquisition: this.noActionAcquisition,
                    actions: ["Eye", "Mouth", "HeadRight", "HeadLeft"],
                    isRandom: true, //采集动作随机 默认按顺序--noActionAcquisition=true无效
                    qualityLevel: 2, //质量等级  0、默认  1、宽松  2、严格
                    timeOut: 15, //单个动作采集时间 --noActionAcquisition=true无效
                    camera: "front", //摄像头 front back 默认前置
                    isSound: true, //语音 
                    isEnableSound: true, //进入采集页面语音播报是否打开(默认不打开 isSound==true有效)
                    tipsTextColor: "#6450a4", //提示文字色值
                    tipSubTextColor: "#ff00ff", //副标题提示语
                    progressBackgroundColor: "#666666", //刻度线背景色
                    progressScaleColor: "#0000ff", //刻度线背色
                    backgroundColor: "#FFFFFF", //背景色
                    bottomCopyright: "这是uts百度离线采集插件", //底部版权文案
                    copyrightColor: "#00ff00", //版权文字色值
                    showBottomImage: true, //显示底部logo图
                    returnResultImage: true, //返回采集图片,默认返回
                    switchCamera: true, //是否可切换摄像头 右上角多个切换摄像头按钮
                    callBack: (res) => {
                        if (res.code == "200") {//鉴权成功

                        } else if (res.code == "201") {//采集成功
                            this.cropImagePath = `${res.originalCropImagePath}`;
                            this.originalImagePath = `${res.originalImagePath}`;
                        } else if (res.code == "100") {//licenseID为空

                        } else if (res.code == "101") {//没有相机权限,请前往设置打开

                        } else {
                            //其他鉴权错误
                        }
                        console.log(res.message)
                    }
                } as BDFace.GatherFaceOptions);
            },
            //删除原图
            removeOriginalImage() {
                BDFace.clearFileWithPath({
                    path: this.originalImagePath,
                    clearCallBack: (res) => {
                        uni.showToast({
                            title: res ? "删除成功" : "删除失败",
                            icon: 'none'
                        })
                    }
                })
            },
            //删除抠图
            removeCropImage() {
                BDFace.clearFileWithPath({
                    path: this.cropImagePath,
                    clearCallBack: (res) => {
                        uni.showToast({
                            title: res ? "删除成功" : "删除失败",
                            icon: 'none'
                        })
                    }
                })
            }
        }
    }
</script>

<style>
    .logo {
        height: 100px;
        width: 100px;
        margin-bottom: 40rpx;
    }

    .title {
        font-size: 18px;
        color: #8f8f94;
        text-align: center;
    }

    .item {
        margin: 100px auto 25px auto;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
    }
</style>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

需要申请相机权限,用于人脸采集功能

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件自身不采集任何数据,插件使用的百度离线人脸采集SDK采集数据,请参考其官方说明:https://ai.baidu.com/ai-doc/FACE/Mk37c1pue

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率: