wx.createVKSession的用法

wx.stopFaceDetect 及 wx.faceDetect及wx.initFaceDetect()接口已确认停止维护,替代方案为 wx.createVKSession

onCameraFrame() {
	// 初始化createVKSession
	this.session = wx.createVKSession({
					track: {
						face: {
							mode: 2
						} // mode: 1 - 手动传入图像;2 - 使用摄像头
					},
				})

 // 摄像头实时检测模式下,监测到人脸时,updateAnchors 事件会连续触发 (每帧触发一次)
			this.session.on('updateAnchors', this.handleUpdateAnchors)
			// 当人脸从相机中离开时,会触发 removeAnchors 事件
			this.session.on('removeAnchors', this.handleremoveAnchors)
				// 需要调用一次 start 以启动
				this.session.start(errno => {
					if (errno) {
						// 如果失败,将返回 errno
					} else {
						// 否则,返回null,表示成功
						this.listener.start()
					}
				})
			},
			
	handleUpdateAnchors(anchors) {
	//监测到人脸时,自己的逻辑
	},
	handleremoveAnchors() {
	//监测到人脸移出时的逻辑
	},

取消监听

this.session.off('updateAnchors', this.handleUpdateAnchors);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值