人脸检测上传图片VKSession.detectFace总是无法触发updateAnchors回调?
init() {
let that = this
const session = this.session = wx.createVKSession({
version: 'v2',
track: {
face: {mode: 2},
plane: {mode: 3}
}
})
// VKSession EVENT updateAnchors
session.on('updateAnchors', anchors => {
console.log('%c =======>anchors', 'color: #6fc1ff; font-weight: bold', anchors)
})
// VKSession removeAnchors
// 识别目标丢失时不断触发
session.on('removeAnchors', anchors => {
that.tipsText = '检测不到人';
that.photoDisabled = true
});
try {
session.start(err => {
if (err) return console.error('VK error: ', err);
});
} catch(e) {
console.error(e);
}
},
handleChooseAlbumImage() {
const that = this
uni.chooseImage({
count: 1,
sourceType: ['album'],
success: async (res) => {
if (res.errMsg === 'chooseImage:ok') {
let path=res.tempFilePaths[0]
uni.getFileSystemManager().readFile({
filePath: path, // 假设只选择了一个图片
success: res => {
let width = ''
let height = ''
uni.getImageInfo({
src: path,
success: function (imageInfo) {
width = imageInfo.width
height = imageInfo.height
that.session.detectFace({
frameBuffer: res.data,
width: width,
height: height,
scoreThreshold: 0.5, // 评分阈值
sourceType: 1,
modelMode: 1
});
}
});
},
fail(res) {
console.error(res)
}
})
}
},
fail: (err) => {
},
});
},