请问楼主问题最后解决了吗?
如何让onCameraFrame 获取的frame数据与相机控件显示范围一致[代码]<!--index.wxml-->[代码][代码]<view class=[代码][代码]"page"[代码][代码]>[代码][代码] [代码][代码]<camera device-position=[代码][代码]"back"[代码] [代码]flash=[代码][代码]"off"[代码] [代码]binderror=[代码][代码]"error"[代码] [代码]frame-size=[代码][代码]"large"[代码] [代码]class=[代码][代码]"mycamera"[代码][代码]>[代码][代码] [代码][代码]</camera>[代码][代码] [代码][代码]<canvas canvas-id=[代码][代码]"mycanvas"[代码] [代码]class=[代码][代码]"mycanvas"[代码][代码]> </canvas>[代码][代码]</view>[代码] [代码]/**index.wxss**/[代码] [代码]page{[代码][代码] [代码][代码]width: 100%;[代码][代码] [代码][代码]height: 100%;[代码][代码]}[代码] [代码].mycamera{[代码][代码] [代码][代码]top:0px;[代码][代码] [代码][代码]width: 100%;[代码][代码] [代码][代码]height: 50%;[代码][代码] [代码][代码]position: fixed;[代码][代码]}[代码] [代码].mycanvas{[代码][代码] [代码][代码]top:50%;[代码][代码] [代码][代码]width: 100%;[代码][代码] [代码][代码]height: 100%;[代码][代码] [代码][代码]background-color: black;[代码][代码] [代码][代码]position: fixed;[代码][代码]}[代码] [代码]//index.js[代码][代码]//获取应用实例[代码][代码]const app = getApp()[代码] [代码]var[代码] [代码]nCounter = 0[代码][代码]var[代码] [代码]listener[代码] [代码]Page({[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]onLoad: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]onReady: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码] [代码][代码]var[代码] [代码]camera_ctx = wx.createCameraContext() [代码][代码] [代码][代码]listener = camera_ctx.onCameraFrame((frame) => { [代码][代码] [代码][代码]if[代码] [代码](nCounter == 0) {[代码][代码] [代码][代码]wx.canvasPutImageData({[代码][代码] [代码][代码]canvasId: [代码][代码]'mycanvas'[代码][代码],[代码][代码] [代码][代码]x: 0,[代码][代码] [代码][代码]y: 0,[代码][代码] [代码][代码]width: frame.width,[代码][代码] [代码][代码]heihgt: frame.heihgt,[代码][代码] [代码][代码]data: [代码][代码]new[代码] [代码]Uint8ClampedArray(frame.data),[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]console.log([代码][代码]'OK'[代码][代码])[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail(res) {[代码][代码] [代码][代码]console.log([代码][代码]'FAIL'[代码][代码])[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]nCounter++[代码][代码] [代码][代码]if[代码] [代码](nCounter >= 10) {[代码][代码] [代码][代码]nCounter = 0[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]listener.start()[代码][代码] [代码][代码]}[代码] [代码]})[代码]- 当前 Bug 的表现(可附上截图) 上面为相机控件显示的内容,下面为canvas显示onCameraFrame获取的frame数据,可见内容并不一致,主要表现是图像显示内容的范围不一致 [图片] - 预期表现 - 复现路径 - 提供一个最简复现 Demo
2021-02-22您好,请问问题解决了吗?解决的话能帮我看一下吗?地址:https://developers.weixin.qq.com/community/develop/doc/000ccc03c9c67051cabbbe98b5d000?jumpto=comment&commentid=000a84c15bc750f1ccbbd798b560
调用 wx.canvasPutImageData 报错调用 wx.canvasPutImageData 接口时报错。 Mon Jul 01 2019 15:14:15 GMT+0800 (中国标准时间) 数据传输错误 invokeCanvasMethod 数据传输长度为 4320165 已经超过最大长度 1048576
2021-02-22请问您解决了吗?我也遇到了
canvasGetImageData和PutImageData接口调用失败wx.canvasGetImageData 、wx.canvasPutImageData两个新接口调用失败,demo如下: var ctx = wx.createCanvasContext('myCanvas'); ctx.setFillStyle('red') ctx.fillRect(0, 0, 200, 200) ctx.draw() wx.canvasGetImageData({ canvasId: 'myCanvas', x: 0, y: 0, width: 200, height: 200, success(res) { console.log(res.width) // 100 console.log(res.height) // 100 console.log(res.data instanceof Uint8ClampedArray) // true console.log(res.data.length) // 100 * 100 * 4 },fail(res){ console.log(res) } }) 打印结果:errMsg:"canvasGetImageData: fail canvas is empty" const data = new Uint8ClampedArray([255, 0, 0, 1]) wx.canvasPutImageData({ canvasId: 'myCanvas', x: 0, y: 0, width: 1, data: data, success(res) {console.log(res)}, fail(res){console.log(res)} }) 打印结果:errMsg:"canvasPutImageData: fail canvas is empty"。 wx.canvasPutImageData 这个接口完全使用官方提供的实例,然而调用结果还是失败。
2021-02-22@官方
wx.canvasPutImageData绘画报错,报错意思为canvas画布为空?需要进行拍照,是用onCameFrame返回数据帧,然后根据返回的frame数据,使用wx.canvasPutImageData绘画,但在绘画时一直报错,错误内容: [图片] 代码片段:https://developers.weixin.qq.com/s/1m8opgme7xoV
2021-02-20请问楼主,您这个问题解决了吗?
textarea真机无法换行?现在这个bug修复了吗?都多久了啊?
2020-12-14