Page({
data: {
faceImgUrl: '',
faceImgBuffer: null,
},
MychooseImg() {
wx.chooseMedia({
count: 1,
mediaType: ['image'],
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: (res) => {
const tempFilePaths = res.tempFiles[0].tempFilePath;
console.log('chooseMedia res', tempFilePaths);
this.setData({
faceImgUrl: tempFilePaths,
})
wx.getImageInfo({
src: tempFilePaths,
success: rep => {
console.log('getImageInfo rep', rep);
const fs = wx.getFileSystemManager();
fs.readFile({
filePath: tempFilePaths,
encoding: 'base64',
success: (res) => {
const base64Data = res.data;
const arrayBuffer = wx.base64ToArrayBuffer(base64Data);
this.setData({
faceImgBuffer: arrayBuffer,
})
console.log(this.data.faceImgBuffer);
this.face();
},
fail: function (err) {
console.error('读取文件失败', err);
}
});
},
})
}
})
},
face() {
console.log('调用face---');
const session = wx.createVKSession({
track: {
face: {
mode: 2
}
},
version: 'v2'
})
session.start(errno => {
if (errno) {
console.log('errno-----', errno);
} else {
console.log(this.data.faceImgBuffer)
session.detectFace({
frameBuffer: this.data.faceImgBuffer,
width: 1080,
height: 1080,
scoreThreshold: 0.9,
sourceType: 1,
modelMode: 1,
open3d: true,
})
console.log('this.session.detectFace', session.detectFace)
}
})
session.on('addAnchors', addAnchors => {
console.log('addAnchors----------', addAnchors);
})
session.on('updateAnchors', updateAnchors => {
console.log('updateAnchors----------', updateAnchors);
anchors.forEach(anchor => {
console.log('anchor.points', anchor.points)
console.log('anchor.origin', anchor.origin)
console.log('anchor.size', anchor.size)
console.log('anchor.angle', anchor.angle)
})
})
}
})
请问有解决吗,官方demo真的是用不了一点