我正在开发一个系统,在浏览器中访问移动设备摄像头,并将摄像头流帧同步发送到另一端。发送的帧在另一侧进一步处理。我已经将帧绘制到画布上,时间间隔如下代码所示。我如何将访问的帧发送到另一端,以便进一步处理帧以同步发生?在画布上绘制的每一帧都将被发送到另一侧,以便在每个图像帧上进行进一步的处理。另一端代码是本地语言。
$<!DOCTYPE html>
<html>
<h1>Simple web camera display demo</h1>
<body>
<video autoplay width="480" height="480" src=""></video>
<canvas width="600" height="480" style="" ></canvas>
<img src="" width="100" height="100" ></img>
<script type="text/javascript">
var video = document.getElementsByTagName('video')[0],
heading = document.getElementsByTagName('h1')[0];
if(navigator.getUserMedia) {
navigator.getUserMedia('video', successCallback, errorCallback);
function successCallback( stream ) {
video.src = stream;
}
function errorCallback( error ) {
heading.textContent =
"An error occurred: [CODE " + error.code + "]";
}
} else {
heading.textContent =
"Native web camera streaming is not supported in this browser!";
}
draw_interval = setInterval(function()
{
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');
var frames = document.getElementById('frames');
ctx.drawImage(document.querySelector("video"), 0, 0);
}, 33)
</script>
</body>
</html>