|
|
|
<!doctype html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<!-- Required meta tags -->
|
|
|
|
<link href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" media="screen">
|
|
|
|
<script src="http://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Live Video Based on Flask</title>
|
|
|
|
<link rel="stylesheet" href='/style.css'/>
|
|
|
|
<style type="text/css">
|
|
|
|
#front {
|
|
|
|
margin-left: 40px;
|
|
|
|
margin-bottom: 3px;
|
|
|
|
}
|
|
|
|
#rear{
|
|
|
|
margin-top: 3px;
|
|
|
|
margin-left: 40px;
|
|
|
|
}
|
|
|
|
.btn{
|
|
|
|
background: #e8080b;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<title>Capture Frame</title>
|
|
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h5>实时视频流</h5>
|
|
|
|
<img src="{{ url_for('startvadio') }}">
|
|
|
|
<button type="button" onclick="capture()" >拍照</button>
|
|
|
|
<button type="button" onclick="startvadio()" >开始视频</button>
|
|
|
|
<button type="button" onclick="stopvadio()" >停止视频</button>
|
|
|
|
<!-- <img id="frameImage" src="" alt="Captured Frame" style="display:none; width: 640px; height: 480px;"> -->
|
|
|
|
<p> 小车控制界面</p>
|
|
|
|
<bodylink = "red">
|
|
|
|
<a href="control" target="_blank">小车控制</a>
|
|
|
|
<div id="container" class="container">
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<button id="front" type="button" onclick="forward()" class="btn btn-lg btn-primary glyphicon glyphicon-circle-arrow-up" style="margin-left: 56px;"> </button>
|
|
|
|
</div>
|
|
|
|
<!-- <div>
|
|
|
|
<button id="printButton" type="button" onclick="printClicked()" class="btn btn-lg btn-primary">打印点击</button>
|
|
|
|
</div> -->
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<button type="button" onclick="left()" class="btn btn-lg btn-primary glyphicon glyphicon-circle-arrow-left" > </button>
|
|
|
|
<button type="button" onclick="stop()" class="btn btn-lg btn-primary glyphicon glyphicon-stop"> </button>
|
|
|
|
<button type="button" onclick="right()" class="btn btn-lg btn-primary glyphicon glyphicon-circle-arrow-right" > </button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<button id="rear" type="button" onclick="back()" class="btn btn-lg btn-primary glyphicon glyphicon-circle-arrow-down" style="margin-left: 56px;"> </button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<button id="up" type="button" onclick="up()" class="btn btn-lg btn-primary glyphicon glyphicon-circle-arrow-up" style="margin-left: 56px;"> </button>
|
|
|
|
</div>
|
|
|
|
<!-- <div>
|
|
|
|
<button id="printButton" type="button" onclick="printClicked()" class="btn btn-lg btn-primary">打印点击</button>
|
|
|
|
</div> -->
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<button type="button" onclick="yunleft()" class="btn btn-lg btn-primary glyphicon glyphicon-circle-arrow-left" > </button>
|
|
|
|
<button type="button" onclick="guiwei()" class="btn btn-lg btn-primary glyphicon glyphicon-stop"> </button>
|
|
|
|
<button type="button" onclick="yunright()" class="btn btn-lg btn-primary glyphicon glyphicon-circle-arrow-right" > </button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<button id="down" type="button" onclick="down()" class="btn btn-lg btn-primary glyphicon glyphicon-circle-arrow-down" style="margin-left: 56px;"> </button>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<form id="sendCommandForm">
|
|
|
|
回复指令: <textarea id="message"></textarea><br>
|
|
|
|
<button type="button" onclick="sendCommand()">发送指令</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script src='/Decoder.js'></script>
|
|
|
|
<script src='/YUVCanvas.js'></script>
|
|
|
|
<script src='/Player.js'></script>
|
|
|
|
<script>
|
|
|
|
// player
|
|
|
|
window.player = new Player({ useWorker: true, webgl: 'auto', size: { width: 848, height: 480 } })
|
|
|
|
var playerElement = document.getElementById('viewer')
|
|
|
|
playerElement.appendChild(window.player.canvas)
|
|
|
|
// Websocket
|
|
|
|
var wsUri = window.location.protocol.replace(/http/,'ws')+'//'+window.location.hostname+':9000'
|
|
|
|
var ws = new WebSocket(wsUri)
|
|
|
|
ws.binaryType = 'arraybuffer'
|
|
|
|
ws.onopen = function (e) {
|
|
|
|
console.log('Client connected')
|
|
|
|
ws.onmessage = function (msg) {
|
|
|
|
// decode stream
|
|
|
|
window.player.decode(new Uint8Array(msg.data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ws.onclose = function (e) {
|
|
|
|
console.log('Client disconnected')
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function sendCommand() {
|
|
|
|
var message = document.getElementById('message').value;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: "/control/sendit",
|
|
|
|
data: JSON.stringify({
|
|
|
|
message: message
|
|
|
|
}),
|
|
|
|
contentType: "application/json",
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result);
|
|
|
|
alert("指令发送成功!");
|
|
|
|
},
|
|
|
|
error: function (error) {
|
|
|
|
console.log('Error:', error);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function capture() {
|
|
|
|
console.log("132465789891651354684");
|
|
|
|
$.ajax({
|
|
|
|
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "capture" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
function startvadio() {
|
|
|
|
// console.log("132465789891651354684");
|
|
|
|
$.ajax({
|
|
|
|
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "startvadio" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
function stopvadio() {
|
|
|
|
// console.log("132465789891651354684");
|
|
|
|
$.ajax({
|
|
|
|
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "stopvadio" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
// $(document).ready(function() {
|
|
|
|
// $('#captureButton').click(function() {
|
|
|
|
// $.ajax({
|
|
|
|
// url: '/capture_frame', // 后端路由地址
|
|
|
|
// type: 'GET',
|
|
|
|
// success: function(response) {
|
|
|
|
// // 将响应中的图像数据设置到img标签的src属性
|
|
|
|
// $('#frameImage').attr('src', 'data:image/jpeg;base64,' + response);
|
|
|
|
// // 显示图像
|
|
|
|
// $('#frameImage').show();
|
|
|
|
// },
|
|
|
|
// error: function(error) {
|
|
|
|
// console.log('Error:', error);
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
function printClicked() {
|
|
|
|
// console.log("132465789891651354684");
|
|
|
|
}
|
|
|
|
|
|
|
|
function forward() {
|
|
|
|
console.log("132465789891651354684");
|
|
|
|
$.ajax({
|
|
|
|
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "/control/forward" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function back() {
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "/control/back" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} function right() {
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "/control/right" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} function left() {
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "/control/left" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} function stop() {
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "/control/stop" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} function up() {
|
|
|
|
// console.log("132465789891651354684");
|
|
|
|
$.ajax({
|
|
|
|
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "/control/up" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} function yunleft() {
|
|
|
|
// console.log("132465789891651354684");
|
|
|
|
$.ajax({
|
|
|
|
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "/control/yunleft" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
function yunright() {
|
|
|
|
// console.log("132465789891651354684");
|
|
|
|
$.ajax({
|
|
|
|
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "/control/yunright" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
function down() {
|
|
|
|
// console.log("132465789891651354684");
|
|
|
|
$.ajax({
|
|
|
|
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "/control/down" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
function guiwei() {
|
|
|
|
// console.log("132465789891651354684");
|
|
|
|
$.ajax({
|
|
|
|
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
url: "/control/guiwei" ,
|
|
|
|
data: $('#form1').serialize(), //提交的数据
|
|
|
|
success: function (result) {
|
|
|
|
console.log(result); //打印服务端返回的数据(调试用)
|
|
|
|
if (result.resultCode == 200) {
|
|
|
|
}
|
|
|
|
;
|
|
|
|
},
|
|
|
|
error : function() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
<script>
|
|
|
|
function refreshPage() {
|
|
|
|
location.reload(); // 刷新页面
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
|
|
|
|
</body>
|
|
|
|
</html>
|