项目导入了tensorflow.js,在app.js 设置了以下代码
//app.js
var fetchWechat = require('fetch-wechat');
var tf = require('@tensorflow/tfjs-core');
var webgl = require('@tensorflow/tfjs-backend-webgl');
var plugin = requirePlugin('tfjsPlugin');
App({
onLaunch() {
plugin.configPlugin({
// polyfill fetch function
fetchFunc: fetchWechat.fetchFunc(),
// inject tfjs runtime
tf,
// inject webgl backend
webgl,
// provide webgl canvas
canvas: wx.createOffscreenCanvas()
});
tf.tensor([1, 2, 3, 4]).print()
}
})
//index.js
Page({
onLoad() {
const camera = wx.createCameraContext(this)
let count = 0
const listener = camera.onCameraFrame(frame=>{
count++
if(count===4) {
console.log(frame)
count = 0
}
})
listener.start()
},
})
由于在开发者工具模式下没法打开camera(不知道为啥不支持,真麻烦),于是按提示开启真机调试,但是却发生了以下错误,请官方人员帮忙查看,感谢
(unknown) SystemError (appServiceSDKScriptError)
Cannot read property 'createOffscreenCanvas' of undefined
TypeError: Cannot read property 'createOffscreenCanvas' of undefined
at eval (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:2104670)
at a (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:2105306)
at Object.n (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:2104139)
at Object.l.<computed> (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:2101353)
at Object.eval (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:1780471)
at Object.eval (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:3258311)
at < at wx.createOffscreenCanvas>
at Object.eval (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:122632)
at wA.onLaunch (weapp:///app.js:18:18)
at wA.eval (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:3575772)
errorReport
(unknown) MiniProgramError
Cannot assign to read only property 'btoa' of object '[object Window]'
TypeError: Cannot assign to read only property 'btoa' of object '[object Window]'
at e ([__wxPluginCode__]:1116:45)
at Object.exports.setupWechatPlatform ([__wxPluginCode__]:1116:1599)
at Object.exports.configPlugin ([__wxPluginCode__]:1072:148)
at wA.onLaunch (weapp:///app.js:10:12)
at wA.eval (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:3575772)
at new wA (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:3576529)
at Function.eval (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:3576841)
at eval (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:3563396)
at eval (weapp:///app.js:8:1)
at require (eval at n.call.document (http://127.0.0.1:45717/remote-debug/runtime.js?devtools_ignore=true:1:13107), <anonymous>:2:3619027)
你好,目前还不支持,请耐心等待后续支持。