首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在websocket上使用broadway.js和raspi-camera时出现问题

在websocket上使用broadway.js和raspi-camera时出现问题
EN

Stack Overflow用户
提问于 2018-07-17 16:36:29
回答 0查看 475关注 0票数 0

我想做的是用PI来控制我造的一辆小车。我想通过一个网页界面来控制这一点,并且还想在驾驶时使用PI-camera来获得实况流。

我在PI上使用nodejs和这个模块:https://www.npmjs.com/package/raspivid-stream从PI-camera获取流。下面是我的nodejs代码:

代码语言:javascript
复制
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:

代码语言:javascript
复制
...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...

到目前为止,我在浏览器控制台中得到了以下错误:

代码语言:javascript
复制
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.

有谁知道怎么解决这个问题吗?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51376752

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档