// pages/audio/index.ts
Page({
/**
* 页面的初始数据
*/
data: {
audioUrl: '',
videoUrl: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
videoCtx = wx.createCameraContext();
let count = 0;
listener = videoCtx.onCameraFrame((frame:any) => {
count++;
if (count === 10) {
this.detectFace(frame);
count = 0;
}
});
VKSession = wx.createVKSession({
version: 'v1',
track: {
plane: {
mode: 1
},
face: { mode: 2 }
}
});
VKSession.on('updateAnchors', (anchors:any) => {
console.warn('anchors', anchors);
})
},
handleStart() {
videoCtx.startRecord({
timeoutCallback: (res:any) => {
console.warn(res);
this.setData({
videoUrl: res.tempVideoPath
})
},
timeout: 300,
complete: (res:any) => {
console.warn('videoCtx.startRecord complete', res);
}
});
VKSession.start((errno:any) => {
console.warn('VKSession.start errno', errno);
});
listener.start();
},
handleStop() {
listener.stop({
complete: (res:any) => {
console.warn('listener.stop', res);
}
});
VKSession.stop();
videoCtx.stopRecord({
compressed: true,
success: (res:any) => {
console.warn('videoCtx.stopRecord success', res);
this.setData({
videoUrl: res.tempVideoPath
})
},
fail: (res:any) => {
console.warn('videoCtx.stopRecord fail', res);
}
});
},
async detectFace(frame:any) {
console.warn(frame.data);
VKSession.detectFace({
frameBuffer: frame.data,
width: frame.width,
height: frame.height,
scoreThreshold: 0.8,
sourceType: 0,
modelMode: 1
});
},
handleError() {},
});
你好,把你的console.warn('anchors', anchors); 改成 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)
})
兄弟给个代码片段,我提供点之前把玩的线索:我碰到开发工具不正常,但是真机正常的情况,感觉是frame的宽和高在开发工具和真机不同导致