Skip to content

Instantly share code, notes, and snippets.

@vivahiraj
Created May 4, 2014 14:44
Show Gist options
  • Save vivahiraj/a8fe861e0d07ea48cc42 to your computer and use it in GitHub Desktop.
Save vivahiraj/a8fe861e0d07ea48cc42 to your computer and use it in GitHub Desktop.
OpenCVで加工した画像をwebsocket経由で受け取るクライアントです
<!doctype html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>WebCam</title>
</head>
<body>
<div id="capture-area">
</div>
<script src="http://codeorigin.jquery.com/jquery-2.0.3.min.js"></script>
<script>
$(function() {
var ws = new WebSocket('ws://raspberrypi.local:51234');
ws.onopen = function() {
$('#capture-area').append($('<img>').attr('id', 'capture'));
$('#capture').css("width","800px");
};
ws.onclose = function() {
};
ws.onmessage = function(evt) {
var src = 'data:image/jpeg;base64,' + evt.data;
$('#capture').attr('src', src);
};
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment