-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
181 lines (181 loc) · 6.45 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>RPi Stereo Cam Stream</title>
<link href="/static/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
#stream {
width: 100%;
height: 100%;
margin: 0px auto;
display: block;
}
.form-inline {
text-align: center;
}
</style>
<script src="/static/jquery-2.1.1.min.js"></script>
<script src="/static/bootstrap.min.js"></script>
<script src="/static/jquery.fileDownload.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
socket.on('liveStream', function(url) {
$('#stream').attr('src', url);
});
socket.on('current-cam-config', function(data) {
if ('ISO' in data)
$('#iso').val(data.ISO);
if ('ss' in data)
$('#shutter').val(data.ss);
});
socket.on('mode', function(mode) {
$('#capture').attr('value', mode);
if (mode === 'test') {
$('#capture').html('Start Capture');
$('#capture').attr('class', 'btn btn-success');
$('#config').attr('disabled', false);
$('#iso').attr('disabled', false);
$('#shutter').attr('disabled', false);
} else if (mode === 'capture') {
$('#capture').html('Stop Capture');
$('#capture').attr('class', 'btn btn-danger');
$('#config').attr('disabled', true);
$('#iso').attr('disabled', true);
$('#shutter').attr('disabled', true);
}
});
socket.on('connect', function() {
socket.emit('start-stream');
});
$(function(){
$('#config').click(function(e){
e.preventDefault();
var data = {};
data.ISO = $('#iso').val();
data.ss = $('#shutter').val();
socket.emit('new-cam-config', data);
});
});
socket.on('image-list', function(image_list) {
$('#image_list').empty();
$('#image_list_text').html('');
var text = 'No images captured.';
if (('dir' in image_list) && ('images' in image_list)) {
var row = '';
for (idx = 0; idx < image_list.images.length; idx++) {
if (idx % 3 == 0) {
if (row.length > 0) {
$('#image_list').append('<div class="row">' + row + '</div>');
row = '';
}
}
row += '<div class="col-md-4"><a href="' +
image_list.dir+'/'+image_list.images[idx]+'" target="_blank">' +
image_list.images[idx] +
'</a></div>';
}
if (row.length > 0) {
$('#image_list').append('<div class="row">' + row + '</div>');
text = '';
}
}
$('#image_list_text').html(text);
});
socket.on('diskinfo', function(diskinfo) {
$('#diskfree').html('');
if (('used' in diskinfo) && ('free' in diskinfo)) {
var newlabel = 'Space left: ' + Math.round(diskinfo.free/(diskinfo.used+diskinfo.free)*100) +
'% (' + Math.round(diskinfo.free/1000000) + '/' +
Math.round((diskinfo.used+diskinfo.free)/1000000) + ' MB)';
$('#diskfree').html(newlabel);
}
});
$(function(){
$('#capture').click(function(e){
e.preventDefault();
var action;
if ($('#capture').val() === 'test')
action = 'start';
else if ($('#capture').val() === 'capture')
action = 'stop';
socket.emit('capture', action);
});
});
$(function(){
$('#images-modal').on('show.bs.modal', function (event) {
$('#image_list').empty();
$('#image_list_text').html('Fetching data ...');
$('#diskfree').html('');
socket.emit('images', 'ls');
});
});
$(function(){
$('#downloadImages').click(function(e){
e.preventDefault();
$.fileDownload('/download');
});
});
$(function(){
$('#deleteImages').click(function(e){
e.preventDefault();
socket.emit('images', 'rm');
});
});
</script>
</head>
<body>
<div class="container">
<h1 class="text-center">
RPi Stereo Camera Live Stream <small>Powered by PI</small>
</h1>
<form class="form-inline">
<div class="form-group">
<label for="iso">ISO</label>
<input type="text" id="iso" value="100" class="form-control">
</div>
<div class="form-group">
<label for="shutter">Exposure Time (µs)</label>
<input type="text" id="shutter" value="800" class="form-control">
</div>
<button id="config" class="btn btn-default">Update Config</button>
<button id="capture" class="btn btn-default"></button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#images-modal">Captured Images</button>
</form>
</div>
<div>
<img src="" id="stream">
</div>
<div class="modal fade" id="images-modal" tabindex="-1" role="dialog" aria-labelledby="images-modal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="ImagesModalLabel">Captured Images</h4>
</div>
<div class="modal-body">
<div class="container-fluid" id="image_list">
</div>
<div>
<p id="image_list_text"></p>
</div>
</div>
<div class="modal-footer">
<span style="float: left;">
<label id="diskfree"></label>
</span>
<span style="float: right;">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button id="downloadImages" type="button" class="btn btn-success">Download All</button>
<button id="deleteImages" type="button" class="btn btn-danger">Delete All</button>
</span>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</body>
</html>