1.
this.listener = this.ctx.onCameraFrame((frame) => {
this.frameData = frame.data;
this.frameWidth = frame.width;
this.frameHeight = frame.height;
that.session.detectFace({
frameBuffer: frame.data,
width: frame.width,
height: frame.height,
scoreThreshold: 0.8,
sourceType: 0,
modelMode: 1,
})
})
this.listener.start()
看检测API
const session = wx.createVKSession({ track: { face: { mode: 1 } // mode: 1 - 使用摄像头;2 - 手动传入图像 }, version: 'v1' }) // 摄像头实时检测模式下,监测到人脸时,updateAnchors 事件会连续触发 (每帧触发一次) session.on('updateAnchors', anchors => { console.log('anchors.points', anchors.points) console.log('anchors.origin', anchors.origin) console.log('anchors.size', anchors.size) console.log('anchors.angle', anchors.angle) }) // 当人脸从相机中离开时,会触发 removeAnchors 事件 session.on('removeAnchors', () => { console.log('removeAnchors') })
https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/face.html