listener = cameraContext.onCameraFrame((frame) => {} //获取相机流
//开始画图
uni.canvasPutImageData({
canvasId: 'monitorCanvas',
//生成图片的偏移量 苹果和安卓有区别
x: 0,
y: 0,
width: frame.width ,
height:frame.height,
data: clamped,
success: (putRes) => {
// console.log(
// 'canvasPutImageData success',
// putRes);
uni.canvasToTempFilePath({
canvasId: 'monitorCanvas',
x: 0,
y: 0,
width: frame
.width * devicePixelRatio,
height: frame
.height * devicePixelRatio,
destWidth: frame
.width * devicePixelRatio,
destHeight: frame
.height * devicePixelRatio,
success: (saveRes) => {
console.log('face Canvas转图片成功',saveRes.tempFilePath,frame.width,frame.height);
//使用
// self.getFileByTmpPath(saveRes.tempFilePath).then(res=>{
// //url、file、width、height
// console.log(res,"使用")
// self.imgUrl=res.url;
// })
//调试图片
self.imgUrl=saveRes.tempFilePath;
// 上传人脸
self.VKverifyFace(saveRes.tempFilePath);
},
fail: (saveErr) => {
console.log('face Canvas转图片失败',saveErr);
}
})
},
fail: (putErr) => {
console.log('canvasPutImageData fail',putErr);
}
}, self);

- 发布:2023-09-05 15:34
- 更新:2023-09-05 15:34
- 阅读:370
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win11
HBuilderX类型: 正式
HBuilderX版本号: 3.8.4
第三方开发者工具版本号: 1.06.2307260
基础库版本号: 3.0.0
项目创建方式: HBuilderX
操作步骤:
预期结果:
代码无异常
代码无异常
实际结果:
代码无异常
代码无异常
bug描述:
微信小程序 在 相机组件流获取到的 数据流 传给 uni.canvasPutImageData 在苹果IOS手机里 会出现画面生成只有四分之1的图 安卓机器却是正常的。 无报错 且 canvasPutImageData的width和height属性 不能手动调 手动调会报错说无效参数
