UniApp百度人脸识别插件YL-FaceDetect-CSDN博客

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

插件地址https://ext.dcloud.net.cn/plugin?id=15061

插件说明

百度离线人脸识别人脸收集属性性别年龄识别等目前只支持安卓端
另该插件支持的功能为属性识别即当人脸出现在摄像头前时会返回性别年龄活体得分是否戴眼镜等信息
不包含其它功能如支付模式闸机模式考勤模式下的人脸认证。
人脸识别成功后保存人脸图片功能为预留功能如有需请联系作者

如有需其它识别功能或更多定制化功能请联系作者QQ:453503875,微信同

百度云官方地址https://console.bce.baidu.com/

请申请离线识别SDK

在这里插入图片描述

在这里插入图片描述

1.使用方法

  • 1.引入插件
const fd = uni.requireNativePlugin("YL-FaceDetect");
  • 2.初始化(注意需要自己在百度后台申请设备授权码个人用户会有两个免费测试授权码)初始化成功后会直接启动摄像头进行识别识别成功会持续返回识别结果
fd.init(this.inputValue, res => {
	this.content = JSON.stringify(res);
});
  • 3.停止、销毁
fd.destroy();

注意使用以上方式可在vue中使用但启动摄像头后不会显示摄像头预览画面插件内部默认了为1像素以满足大部分用户的无感知识别需求。

如果想显示预览画面插件为你提供了view的方式但必须使用nvue


<yl-face-view ref="fd" style="width: 300;height: 600;"></yl-face-view>

然后使用ref初始化

this.$refs.fd.init(this.inputValue, res => {
					this.content = JSON.stringify(res);
				});

如果你想使用vue引入插件并且要显示预览画面或者有其它方面的需求可联系本人

代码示例


<template>
	<div style="padding: 20rpx;">

		<input placeholder="输入lisenseId" style="height: 100rpx;padding: 0 20rpx;border: 1px solid red;margin: 20rpx 0;"
			v-model="inputValue" />

		<button type="primary" style="margin: 20rpx 0;" plain="true" @click="init()">开始识别</button>
		<button type="primary" style="margin: 20rpx 0;" plain="true" @click="stop()">停止识别</button>

		<view class="text" style="margin: 20rpx 0;">
			<text>{{content}}</text>
		</view>

	</div>
</template>

<script>
	// 获取 module 
	const fd = uni.requireNativePlugin("YL-FaceDetect");

	export default {
		data() {
			return {
				inputValue: "",
				content: ""
			}
		},
		mounted() {

		},
		beforeDestroy() {
			this.stop();
		},
		methods: {
			init() {
				fd.init(this.inputValue, res => {
					this.content = JSON.stringify(res);
				});
			},
			stop() {
				fd.destroy();
			}
		}
	}
</script>

<style>
	.text {
		line-height: 1.5;
		text-align: justify;
		word-wrap: break-word;
	}
</style>

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6