我想做的是用PI来控制我造的一辆小车。我想通过一个网页界面来控制这一点,并且还想在驾驶时使用PI-camera来获得实况流。
我在PI上使用nodejs和这个模块:https://www.npmjs.com/package/raspivid-stream从PI-camera获取流。下面是我的nodejs代码:
var raspividStream = require('raspivid-stream');
var stream = raspividStream();
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
stream.on('data', (data) => {
ws.send(data, { binary: true }, (error) => { if (error) console.error(error);
});
});下面是index.html:
...htmlstuff...
<canvas id="stream"></canvas>
<script src="decoder.js"></script>
<script src="player.js"></script>
<script>
var connection = new WebSocket('ws://raspberrypi:8443');
var p = new Player();
p.canvas = document.getElementById("stream"); // the canvas - p$
connection.onopen = function () {
connection.send('Ping'); // Send the message 'Ping' to $
};
connection.onerror = function (error) {
console.log('WebSocket Error ' + error);
};
connection.onmessage = function (e) {
console.log(e.data);
p.decode(e);
};
</script>
...htmlstuff...到目前为止,我在浏览器控制台中得到了以下错误:
wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.
falling back to ArrayBuffer instantiation
failed to asynchronously prepare wasm: CompileError: AsyncCompile: Wasm decoding failed: expected magic word 00 61 73 6d, found 3c 21 44 4f @+0
CompileError: AsyncCompile: Wasm decoding failed: expected magic word 00 61 73 6d, found 3c 21 44 4f @+0
Uncaught (in promise) abort({}). Build with -s ASSERTIONS=1 for more info.有谁知道怎么解决这个问题吗?
https://stackoverflow.com/questions/51376752
复制相似问题