- cameraContext.onCameraFrame((frame) =>{获取像素问题}?
尊敬的微信团队,求教一个问题,新手,实在搞不懂。 cameraContext.onCameraFrame((frame) => { let uint8Array=new Uint8ClampedArray(frame.data); for(var h=0;h<height;h++) { for(var w=0;w<width;w++) { var pixelIndex=((h*width)+w)*4;//rgba; var pixelRed=uint8Array[pixelIndex]; var pixelGreen=uint8Array[pixelIndex+1]; var pixelBlue=uint8Array[pixelIndex+2]; } } } 问题: 上代码获取pixelRed和pixelGreen和pixelBlue都为零?想获取pixelBlue的值0~255,如何实现,谢谢了。 麻烦回复,恳教大家帮帮忙,就是要从frame.data获取每个像素点的r g b值。麻烦了。
2021-04-21 - 如何引用crypto,const crypto = require("crypto");报错?
确认安装了nodejs -v v14.16.0 在微信开发工具 const crypto = require("crypto"); 报 "crypto.js" is not defined. 外部命令 node v3.js没有报错,但是开发工具const crypto = require("crypto");老是报错,请问如何解决?麻烦了。 const crypto = require('crypto'); function sha256(message, secret = '', encoding) { const hmac = crypto.createHmac('sha256', secret) return hmac.update(message).digest(encoding) } function getHash(message, encoding = 'hex') { const hash = crypto.createHash('sha256') return hash.update(message).digest(encoding) } function getDate(timestamp) { const date = new Date(timestamp * 1000) const year = date.getUTCFullYear() const month = ('0' + (date.getUTCMonth() + 1)).slice(-2) const day = ('0' + date.getUTCDate()).slice(-2) return `${year}-${month}-${day}` } function main(){ // 密钥参数 const SECRET_ID = "Aetet*" const SECRET_KEY = "sdfasdf" const endpoint = "iai.tencentcloudapi.com" const service = "iai" const region = "ap-beijing" const action = "DetectFace" const version = "2020-03-03" //const timestamp = getTime() const timestamp = Math.round(new Date().getTime()/1000) + ""; //时间处理, 获取世界时间日期 const date = getDate(timestamp) // ************* 步骤 1:拼接规范请求串 ************* const signedHeaders = "content-type;host" const payload = "{\"Image\": \"\"}" const hashedRequestPayload = getHash(payload); const httpRequestMethod = "POST" const canonicalUri = "/" const canonicalQueryString = "" const canonicalHeaders = "content-type:application/json; charset=utf-8\n" + "host:" + endpoint + "\n" const canonicalRequest = httpRequestMethod + "\n" + canonicalUri + "\n" + canonicalQueryString + "\n" + canonicalHeaders + "\n" + signedHeaders + "\n" + hashedRequestPayload console.log(canonicalRequest) console.log("----------------------------") // ************* 步骤 2:拼接待签名字符串 ************* const algorithm = "TC3-HMAC-SHA256" const hashedCanonicalRequest = getHash(canonicalRequest); const credentialScope = date + "/" + service + "/" + "tc3_request" const stringToSign = algorithm + "\n" + timestamp + "\n" + credentialScope + "\n" + hashedCanonicalRequest console.log(stringToSign) console.log("----------------------------") // ************* 步骤 3:计算签名 ************* const kDate = sha256(date, 'TC3' + SECRET_KEY) const kService = sha256(service, kDate) const kSigning = sha256('tc3_request', kService) const signature = sha256(stringToSign, kSigning, 'hex') console.log(signature) console.log("----------------------------") // ************* 步骤 4:拼接 Authorization ************* const authorization = algorithm + " " + "Credential=" + SECRET_ID + "/" + credentialScope + ", " + "SignedHeaders=" + signedHeaders + ", " + "Signature=" + signature console.log(authorization) console.log("----------------------------") const Call_Information = 'curl -X POST ' + "https://" + endpoint + ' -H "Authorization: ' + authorization + '"' + ' -H "Content-Type: application/json; charset=utf-8"' + ' -H "Host: ' + endpoint + '"' + ' -H "X-TC-Action: ' + action + '"' + ' -H "X-TC-Timestamp: ' + timestamp.toString() + '"' + ' -H "X-TC-Version: ' + version + '"' + ' -H "X-TC-Region: ' + region + '"' + " -d '" + payload + "'" console.log(Call_Information) } main()
2021-03-15 - 支付回调:有返回成功信息,还是多次回调?
支付成功后,回调时,回复了下面信息: <xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml> 还是执行十次以上回调,如何处理,谢谢!
2021-02-28 - <canvas type="2d" id="canva"/> .exec((res) =>执行错误?
尊敬的微信团队: <canvas type="2d" id="canvas'"/> const query = wx.createSelectorQuery() query.select('#canvas').fields({ node: true, size: true }) .exec((res) => {} 执行这一句老是提示:TypeError: Cannot read property 'createView' of undefined错误,如果去除type="2d"就不会错误,但是获取不到node,node==null; }); 求人,谢谢。
2021-02-23 - 问onUploadTaskStateChange 1、2、3、4... not found问题?
问下大家,我的var uploadTask=wx.uploadFile({...})老是出现了onUploadTaskStateChange 1、2、3、4... not found问题,请问如何解决? 还有,wx.uploadFile在执行中如何中断它? 谢谢!
2021-02-16 - canvasToTempFilePath第二参数无论怎么整都是fail canvas is emp?
下面代码,无论that放哪里,怎么整都提示:fcanvasToTempFilePath: fail canvas is empty,真是无语,麻烦求解,谢谢。 onReady: function () { var that = this; var context = wx.createCanvasContext('mycanvas',that); wx.chooseImage ({ success: function (res) { context.drawImage(res.tempFilePaths[0], 0, 0, 150, 100); context.fillStyle = "#FF0000"; context.fillRect(0, 0, 50, 50); context.draw(true, setTimeout(function() { wx.canvasToTempFilePath ({ destWidth: 150, destHeight: 100, canvasId: 'mycanvas', success: function (res) { console.log('1212' + res.tempFilePath); }, fail: function (res) {console.log(res);} },that); },300)); } }); }
2021-01-04 - 问userInfo: {}什么意思?userInfo: {}和userInfo: null区别?
问userInfo: {}什么意思?userInfo: {}和userInfo: null区别?
2020-12-22 - Stable 1.03.2011120版本在代码前面数字点击,不会出现断点背景。求问?谢谢。
Stable 1.03.2011120版本在代码前面数字点击,不会出现断点背景。求问。谢谢。
2020-12-22 - 本地调试统一下单签名成功,但同样代码放服务器就出现签名错误。
尊敬微信团队,问服务器统一下单签名错误。 我的商户:1489601702 以前服务器统一下单正常,换了服务器106.55.172.80后,下单提示签名错误。 同样代码、参数、内容随便本地找台电脑和ip进行下单调试都能正常获取到返回的成功信息,就是同样代码、内容、参数 放到106.55.172.80服务器就是出现签名错误,无语,求解?密匙重置了好多次,服务器重启很多次,依然签名错误。 <xml> <appid>wx2d7d9b2a8a33335e</appid> <body>yy</body> <mch_id>1489601702</mch_id> <nonce_str>mn7bbn8smej4bn1t99a3ho6tgyk9in2k</nonce_str> <notify_url>http://ee.playcn.xyz/payback</notify_url> <out_trade_no>47466267423909804836512093020612</out_trade_no> <total_fee>25</total_fee> <trade_type>NATIVE</trade_type> </xml> 问上面xml有哪些问题?
2020-07-30