我要做的功能是在微信小程序上使用人脸识别接口然后获取人物的整个头部,这个时候用到了uni.canvasToTempFilePath。
直接上代码吧。
this.context.fillStyle = '#ffffff';
this.context.fillRect(0, 0, image.width, image.height);
this.context.draw(true,()=>{
this.context.drawImage(path, 0, 0, image.width, image.height)
this.context.draw(true,()=>{
uni.canvasToTempFilePath({
x: this.rect.x,
y: this.rect.y,
width: this.rect.width,
height: this.rect.height,
destWidth: this.rect.width,
destHeight: this.rect.height,
canvasId: 'myCanvas',
success: function(res) {
// 在H5平台下,tempFilePath 为 base64
console.log(res)
_this.url = res.tempFilePath;
}
})
})
})
1 个评论
要回复文章请先登录或注册
2***@qq.com