位置: IT常识 - 正文

UNI-APP 人脸识别分析及实现(前端)(unik面部识别怎么用)

编辑:rootadmin
UNI-APP 人脸识别分析及实现(前端) APP开发一个人脸识别,实现刷脸功能实现流程:

推荐整理分享UNI-APP 人脸识别分析及实现(前端)(unik面部识别怎么用),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:uniapp人脸识别打卡,uniapp人脸识别登录,uniapp人脸识别身份证,uniapp人脸识别方案,uniapp人脸识别上传,uniapp人脸识别上传,uniapp人脸识别上传,uniapp人脸识别方案,内容如对您有帮助,希望把文章链接给更多的朋友!

UNI-APP 人脸识别分析及实现(前端)(unik面部识别怎么用)

1、打开摄像头——自动读取照片——传输给后端——后端交由第三发或自主开发来识别——返回结果(相识度比) 2、打开摄像头——自动读取视频——传输给后端——后端通过解析视频,截取图片交由第三发或自主开发来识别——返回结果(相识度比) 通过分析,只需要做两步骤:打开摄像头和自动读取视频或照片

打开摄像头

分步骤分析:打开摄像头,并展示视频效果在html上,目前有两种方式: 1、使用camera组件进行,借用.createcameracontext()对象来打开摄像头(由于平台差异,uniapp不能在App、H5、支付宝/字节跳动/飞书/360小程序中使用) 2、通过livepusher对象(直播推流技术)实现视频预览和截屏 现在就有两种获取推流的方式了:第一种是nvue开发,第二种vue开发 如果是nvue开发,可以直接使用live-pusher组件进行直播推流,如果是vue开发,则需要使用h5+的plus.video.LivePusher对象来获取

使用NVUE来开发人脸识别

实际实现流程:调用手机摄像头创建直播推流 → 自动截图 → 压缩图片为base64格式→ 上传图片到服务器 → 服务器调用阿里人脸api → 阿里api返回该图片与底图的相似度

html部分<template> <view><div class="custom" :style="{height: CustomBar+'px'}"><view class="navcontent" :style="[{top:statusBar + 'px'}]"><text style="color: #FFFFFF;font-size: 16px;line-height: 45px;" class="iconfont icon-xiangzuo" @click="BackPage">返回</text><text style="color: #FFFFFF;font-size: 16px;line-height: 45px;">人脸识别</text><text></text></view></div> <div class="livefater"><div style="width: 350px;height: 350px;border-radius: 350px;overflow: hidden;background-color: #CCCCCC;"><live-pusher id='livePusher' ref="livePusher" class="livePusher" url=""mode="SD" :muted="true" :enable-camera="true" :auto-focus="true" :beauty="1" whiteness="2"aspect="1:1" @statechange="statechange" @netstatus="netstatus" @error = "error"></live-pusher></div><cover-image src="../static/image/gai.png" class="gaiimg"></cover-image></div> <button class="btn" @click="startPreview">打开摄像头进行人脸识别</button> </view></template>js部分 export default { data: { fil: true,imgList:[""],statusBar:'',CustomBar: 0 },onLoad(){// this.startPreview()}, onReady() { // 注意:需要在onReady中 或 onLoad 延时 this.context = uni.createLivePusherContext("livePusher", this);var that = thisuni.getSystemInfo({ success:function(e){ // 计算导航栏高度that.statusBar = e.statusBarHeight // #ifndef MP if(e.platform == 'android') { that.CustomBar = e.statusBarHeight + 50 }else { that.CustomBar = e.statusBarHeight + 45 } console.log(that.statusBar)// #endif // #ifdef MP-WEIXIN let custom = wx.getMenuButtonBoundingClientRect() that.CustomBar = custom.bottom + custom.top - e.statusBarHeight // #endif // #ifdef MP-ALIPAY that.CustomBar = e.statusBarHeight + e.titleBarHeight // #endif }}) }, methods: {Timer(){}, statechange(e) { console.log("statechange:" + JSON.stringify(e)); }, netstatus(e) { console.log("netstatus:" + JSON.stringify(e)); }, error(e) { console.log("error:" + JSON.stringify(e)); }, start: function() { this.context.start({ success: (a) => { console.log("livePusher.start:" + JSON.stringify(a)); } }); }, close: function() { this.context.close({ success: (a) => { console.log("livePusher.close:" + JSON.stringify(a)); } }); },// 拍照事件 snapshot: function() {var that = this this.context.snapshot({ success: (e) => { console.log(JSON.stringify(e));that.getMinImage(e.message.tempImagePath) } }); },// 开启摄像头 startPreview() {console.log("1")var that = this this.context.startPreview({ success: (a) => { console.log("livePusher.startPreview:" + JSON.stringify(a));that.Timer = setInterval(function(){that.snapshot()if(that.imgList.length>3){console.log("3")clearInterval(that.Timer)}},2000) } }); },// 使用plus.zip.compressImage压缩图片并转换成base64getMinImage(imgPath) {plus.zip.compressImage({src: imgPath,dst: imgPath,overwrite: true,quality: 40},zipRes => {setTimeout(() => {var reader = new plus.io.FileReader();reader.onloadend = res => {var speech = res.target.result; //base64图片console.log(speech);this.imgList.push(speech);};//一定要使用plus.io.convertLocalFileSystemURL将target地址转换为本地文件地址,否则readAsDataURL会找不到文件reader.readAsDataURL(plus.io.convertLocalFileSystemURL(zipRes.target));}, 1000);},function(error) {console.log('Compress error!', error);});},BackPage() {uni.navigateBack({delta: 1});} } }css部分.custom{background-color: #2C65F7;}.navcontent{height: 45px;display: -ms-flex;display: -webkit-flex;display: flex;justify-content:space-around;flex-direction:row;color:#FFFFFF;}.livePusher{width: 350px;height: 350px;}.livefater{display: -ms-flex;display: -webkit-flex;display: flex;justify-content:center;flex-direction:column;align-items:center;margin-top: 50rpx;margin-bottom: 50rpx;height: 350px;}.gaiimg{width: 350px;height: 350px;margin-top: -350px;}使用微信小程序开发人脸识别

微信小程序开发人脸识别,有很大的限制,在于资质审核。 微信文档

本文链接地址:https://www.jiuchutong.com/zhishi/283737.html 转载请保留说明!

上一篇:无痛人流多少钱(无痛人流多少钱?)

下一篇:最新小程序反编译详细教程,亲测可用(小程序在线反编译网页版)

  • 事业单位交所得税是否可以报国高新
  • 增值税进项税抵扣时间
  • 纳税标准怎么算
  • 计提的成本次月怎么处理
  • 服务收入属于什么会计要素
  • 更换电脑后个税信息如何导入
  • 利润表中第3栏营业税金及附加等于什么
  • 航运(集团)招聘
  • 土地补偿款涉及哪些法律
  • 缴纳土地增值税
  • 公司账上的应付账款是指
  • 个人工资怎么缴纳个人所得税
  • 社保扣款不成功会短信提醒吗
  • 买卖汇票是什么意思
  • 公司章程上的出资时间2050年
  • 个税手续费返还会计分录
  • 注销公司税务一年几次
  • 0申报的清算所得税申报表怎么填
  • 销售佣金税点
  • 包装物押金如何确定销售额?
  • 契税纳税义务发生时间税屋
  • 财务报表申报完可以修改吗
  • 销项税现金流量表在附表中如何列示
  • linux 列表
  • 计提长期待摊费用的会计分录
  • 代开增值税发票沒有付款怎么做账?
  • 非货币性资产交换的记忆口诀
  • PHP daddslashes 使用方法介绍
  • 红字发票信息表填好后再怎么操作
  • vue移动和pc两套代码
  • php封包
  • 企业所得税税金及附加包括
  • 细说php
  • 【Vue】踩坑日记:Scoped下动画无效,曾经以为百利而无一害的Scoped,也有自己的限制
  • 旅游业发票怎么抵扣
  • 跨年专票红冲步骤
  • 招待费的进项税必须认证后转出吗
  • 物流公司开几个点的发票
  • 什么是劳务派遣制员工
  • 交易性金融资产处置时的会计核算步骤
  • 退回的个税手续费计入什么科目
  • python获取某个值
  • 其它应收款的处理程序
  • 一般纳税人认定管理办法
  • sql server 2005数据迁移
  • 凭证字号和凭证编号一样吗
  • 可供出售金融资产新准则叫什么
  • 行程单入账多久钱能到账
  • 房地产资质代办需要多少钱
  • 采购商品未入库已经付款会计分录
  • 研发产品入库
  • 收到其他公司往来款怎么做账
  • 应付账款的主要风险点
  • 财产裁定书
  • 高速etc发票如何打印
  • 运费是属于什么会计科目
  • 企业内建立小企业属于哪个阶段
  • mysql数据库简单介绍
  • xampp修改mysql默认密码的方法
  • unix的文件系统采用
  • gitlab linux
  • win8的应用商店
  • windowsxp怎么改windows7
  • windows7能玩地下城吗
  • 升级windows8
  • linux压缩文件tar命令
  • linux必学的60个命令rar
  • mac 安卓系统
  • UNITY开发数字孪生
  • linux的sed -i
  • js匿名类
  • jquery遍历div子元素
  • dom4j解析xml字符串步骤
  • javascript中window对象的子对象不包含
  • python flask
  • python字符串字符对应个数
  • 重庆沙坪坝区沙磁巷幼儿园
  • 新乡市国家税务局刘磊
  • 重庆新电子税务局入口
  • 留抵税额退税政策2023
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设