2024/3/26 依然闪退
微信小程序VKSession.runOCR启动闪退const session = wx.createVKSession({ track: { OCR: { mode: 2 } // mode: 1 - 使用摄像头;2 - 手动传入图像 }, version: 'v1' }); // 静态图片检测模式下,每调一次 runOCR 接口就会触发一次 updateAnchors 事件 session.on('updateAnchors', (anchors) => { uni.showToast({ icon: 'none', title: ''.concat(anchors.map((anchor) => anchor.text)) }); console.log('anchors.text', ''.concat(anchors.map((anchor) => anchor.text))); }); // 需要调用一次 start 以启动 session.start((errno) => { if (errno) { // 如果失败,将返回 errno console.log(errno, '检测失败'); } else { // 否则,返回null,表示成功 uni.showToast({ icon: 'none', title: '检测启动中' }); session.runOCR({ frameBuffer: arrayBuffer, // 图片 ArrayBuffer 数据。待检测图像的像素点数据,每四项表示一个像素点的 RGBA width: that.ocrImg.width, // 图像宽度 height: that.ocrImg.height // 图像高度 }); } }); },
03-26同样闪退 const session = wx.createVKSession({ track: { OCR: { mode: 2 } // mode: 1 - 使用摄像头;2 - 手动传入图像 }, }) // 静态图片检测模式下,每调一次 runOCR 接口就会触发一次 updateAnchors 事件 session.on('updateAnchors', anchors => { console.log('anchors.text', anchors) }) // 需要调用一次 start 以启动 session.start(errno => { if (errno) { // 如果失败,将返回 errno } else { // 否则,返回null,表示成功 session.runOCR({ frameBuffer, width, // 图像宽度 height, // 图像高度 }) } })
VKSession.runOCR拿不到返回值,安卓端闪退https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.runOCR.html const version = wx.isVKSupport('v2') ? 'v2' : (wx.isVKSupport('v1') ? 'v1' : ''); if (version) { const session = wx.createVKSession({ version: version, track: { plane: {mode: 3}, OCR: { mode: 2 } // mode: 1 - 使用摄像头;2 - 手动传入图像 }, }); session.start(errno => { if (errno) { } else { session.runOCR({ frameBuffer:imgData.data.buffer, width: imgData.width, height: imgData.height }) } }); session.on('addAnchors', anchors => { console.log("anchor add", anchors); }) session.on('updateAnchors', anchors => { console.log("anchor updateAnchors", anchors); }); session.on('removeAnchors', anchors => { console.log('anchor remove', anchors); })
03-26真机调试环境 2024/3/26 依然为null
wx.createOffscreenCanvas返回null?onLoad() { const canvas = wx.createOffscreenCanvas({ type: '2d', width: 300, height: 150 }) console.log(canvas) } 打印出来是null
03-260.4.0 一样的情况。。。
0.3.1版本英文单词word-break:break-all,且不能继承父元素的样式回归0.3.0版本就可以了
2021-11-24下面是我的临时解决方案:使用fsock自己写了个上传。。。 /** * 临时上传 * * @param string $url * @param array $params * @return string */ function api_upload(string $url, array $params = []): string { $timeout = 20; $urls = parse_url($url); $scheme = $urls['scheme']; $port = $urls['port'] ?? ($scheme == 'https' ? 443 : 80); $host = $urls['host']; $boundary = '---------------------------' . substr(md5(rand(0, 32000)), 0, 10); $data = '--' . $boundary . "\r\n"; foreach ($params as $key => $val) { if ($val instanceof CURLFile) { $filename = $val->getPostFilename(); $mimetype = $val->getMimeType(); $content = file_get_contents($val->getFilename()); $data .= "content-disposition: form-data; name=\"" . $key . "\"; filename=\"" . $filename . "\"\r\n"; $data .= "content-type: " . $mimetype . "\r\n\r\n"; $data .= $content . "\r\n"; $data .= "--" . $boundary . "\r\n"; } else { $data .= "Content-Disposition: form-data; name=\"" . $key . "\"\r\n"; $data .= "Content-type:text/plain\r\n\r\n"; $data .= rawurlencode($val) . "\r\n"; $data .= "--$boundary\r\n"; } } $data .= "--\r\n\r\n"; $out = "POST " . $url . " HTTP/1.1\r\n"; $out .= "host: " . $host . "\r\n"; $out .= "content-type: multipart/form-data; boundary=" . $boundary . "\r\n"; $out .= "content-length: " . strlen($data) . "\r\n"; $out .= "connection: close\r\n\r\n"; $out .= $data; if ($scheme == 'https') { $context = stream_context_create([ 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false ] ]); $hostname = "ssl://$host:$port"; $fp = stream_socket_client($hostname, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context); } else { $fp = fsockopen($host, $port, $errno, $errstr, $timeout); } fputs($fp, $out); $res = ''; while ($row = fread($fp, 4096)) { $res .= $row; } fclose($fp); $pos = strpos($res, "\r\n\r\n"); $res = substr($res, $pos + 4); return $res; } $token = '...'; $r = api_upload("https://api.weixin.qq.com/cgi-bin/media/upload?access_token=$token&type=image",[ 'media' => new CURLFile('F:\web\aaa.jpg', 'image/jpeg', 'aaa.jpg'), ]); var_dump($r);
php7.4 上传临时素材无法成功php7.4使用curl上传临时素材,API返回空白(The requested URL returned error: 412 Precondition Failed),http状态码412 https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html 同样的反馈帖子: https://developers.weixin.qq.com/community/develop/doc/000a6ca7ae4988a4d9f949d4456800 https://developers.weixin.qq.com/community/develop/doc/0004089f8d078823aef9b63655b400 <?php # 下面是我的测试代码: $url = 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=...&type=image'; $data = [ 'media' => new CURLFile('F:\web\30101441194a79ab.jpg') ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $res= curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); echo '<pre>'; var_dump($res); var_dump($info); echo '</pre>'; ?>
2020-10-27我也遇到这个问题了。 https://developers.weixin.qq.com/community/develop/doc/0006ece2ed888064a92bbaacd54c00
php7.4 上传临时素材成功时候返回为空https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Adding_Permanent_Assets.html php7.4上传素材时,错误时正常返回,正常提交,返回为空。
2020-10-27我也遇到这个问题了。 https://developers.weixin.qq.com/community/develop/doc/0006ece2ed888064a92bbaacd54c00
php7.4 上传临时素材无法成功https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Adding_Permanent_Assets.html php 7.4 curl提交文件时, 请求头以transferencoding:chunked的方式提交, 此方式不会提交Content-Length, 腾讯这边这个请求头似乎是必须的,所以校验不通过,响应码412,希望改进,支持transferencoding:chunked的方式提交文件。
2020-10-27