-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathCameraSettings.html
319 lines (308 loc) · 12.9 KB
/
CameraSettings.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<!DOCTYPE html>
<html>
<head>
<title>Micropython Camera Stream</title>
<style>
body {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
.container {
display: flex;
flex-direction: row;
height: 100%;
width: 100%;
}
.settings-container {
display: flex;
flex-direction: column;
padding: 20px;
background-color: #ffffff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
margin-top: 20px;
width: 300px;
}
.setting {
margin-bottom: 10px;
}
.hidden {
display: none;
}
.video-container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
padding: 20px;
}
img {
width: auto;
height: 100%;
}
.title-container {
width: 100%;
text-align: center;
background-color: #ffffff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
</style>
<script>
function updateValue(method, value) {
console.log(`Updating ${method} to ${value}`);
fetch(`/set_${method}?value=${value}`)
.then(response => {
if (!response.ok) {
console.error(`Error setting ${method}`);
}
})
.catch(error => {
console.error(`Fetch error: `, error);
});
}
function fetchValue(method, type = 'range') {
console.log(`Fetching ${method}`);
fetch(`/get_${method}`)
.then(response => response.text())
.then(value => {
const element = document.getElementById(method);
if (type === 'checkbox') {
element.checked = value === "True";
} else {
element.value = value;
}
})
.catch(error => {
console.error(`Fetch error: `, error);
});
}
function setupEventListeners() {
const inputs = document.querySelectorAll('input');
inputs.forEach(input => {
const type = input.type === 'checkbox' ? 'checkbox' : 'range';
input.addEventListener(type === 'checkbox' ? 'change' : 'input', () => {
const value = type === 'checkbox' ? (input.checked ? 1 : 0) : input.value;
updateValue(input.id, value);
});
fetchValue(input.id, type);
});
const selects = document.querySelectorAll('select');
selects.forEach(select => {
select.addEventListener('change', () => updateValue(select.id, select.value));
fetchValue(select.id, 'select');
});
}
function populateFrameSizeDropdown() {
const frameSizes = [
"R96x96", "QQVGA", "128X128", "CIF", "HQVGA", "R240x240", "QVGA",
"320X320","CIF", "HVGA", "VGA", "SVGA", "XGA", "HD", "SXGA",
"UXGA", "FHD", "P_HD", "P_3MP", "QXGA", "QHD", "WQXGA", "P_FHD", "QSXGA"
];
const frameSizeDropdown = document.getElementById('frame_size');
fetch('/get_max_frame_size')
.then(response => response.text())
.then(maxFrameSize => {
const maxSizeIndex = parseInt(maxFrameSize, 10);
frameSizeDropdown.innerHTML = '';
frameSizes.forEach((size, index) => {
if (index <= maxSizeIndex) {
const option = document.createElement('option');
option.value = index;
option.textContent = size;
frameSizeDropdown.appendChild(option);
}
});
})
.catch(error => {
console.error('Error fetching max frame size:', error);
});
}
function checkSensorFeatures() {
fetch('/get_sensor_name')
.then(response => response.text())
.then(sensorName => {
const showSharpnessAndDenoise = (sensorName === 'OV3660' || sensorName === 'OV5640');
document.getElementById('sharpness-container').classList.toggle('hidden', !showSharpnessAndDenoise);
document.getElementById('denoise-container').classList.toggle('hidden', !showSharpnessAndDenoise);
})
.catch(error => {
console.error('Error fetching sensor name:', error);
});
fetch('/get_pixel_format')
.then(response => response.text())
.then(pixelFormat => {
const showJpegQuality = (pixelFormat === '4');
document.getElementById('quality').parentElement.classList.toggle('hidden', !showJpegQuality);
})
.catch(error => {
console.error('Error fetching pixel format:', error);
});
}
document.addEventListener("DOMContentLoaded", () => {
populateFrameSizeDropdown();
setupEventListeners();
checkSensorFeatures();
});
</script>
</head>
<body>
<div class="title-container">
<h1>Micropython Camera Stream</h1>
</div>
<div class="container">
<div class="settings-container">
<div class="setting">
<label for="frame_size">Frame Size:</label>
<select id="frame_size">
<option value="0">R96x96</option>
<option value="1">QQVGA</option>
<option value="2">128X128</option>
<option value="3">QCIF</option>
<option value="4">HQVGA</option>
<option value="5">R240x240</option>
<option value="6">QVGA</option>
<option value="7">320X320</option>
<option value="8">CIF</option>
<option value="9">HVGA</option>
<option value="10">VGA</option>
<option value="11">SVGA</option>
<option value="12">XGA</option>
<option value="13">HD</option>
<option value="14">SXGA</option>
<option value="15">UXGA</option>
<option value="16">FHD</option>
<option value="17">P_HD</option>
<option value="18">P_3MP</option>
<option value="19">QXGA</option>
<option value="20">QHD</option>
<option value="21">WQXGA</option>
<option value="22">P_FHD</option>
<option value="23">QSXGA</option>
<option value="24">5MP</option>
</select>
</div>
<div class="setting">
<label for="quality" title="Quality above 90% may lead to freezing the camera at high resolutions.">JPEG quality:</label>
<input type="range" id="quality" min="0" max="100">
</div>
<div class="setting">
<label for="contrast">Contrast:</label>
<input type="range" id="contrast" min="-2" max="2">
</div>
<div class="setting">
<label for="brightness">Brightness:</label>
<input type="range" id="brightness" min="-2" max="2">
</div>
<div class="setting">
<label for="saturation">Saturation:</label>
<input type="range" id="saturation" min="-2" max="2">
</div>
<div class="setting">
<label for="aec_value">Exposure Value:</label>
<input type="range" id="aec_value" min="0" max="1200">
</div>
<div class="setting">
<label for="agc_gain">Gain Level:</label>
<input type="range" id="agc_gain" min="0" max="30">
</div>
<div id="sharpness-container" class="setting hidden">
<label for="sharpness">Sharpness:</label>
<input type="range" id="sharpness" min="-3" max="3">
</div>
<div id="denoise-container" class="setting hidden">
<label for="denoise">Denoise:</label>
<input type="range" id="denoise" min="0" max="8">
</div>
<div class="setting">
<label for="gainceiling">Gain Ceiling:</label>
<select id="gainceiling">
<option value="0">2X</option>
<option value="1">4x</option>
<option value="2">8x</option>
<option value="3">16x</option>
<option value="4">32x</option>
<option value="5">64x</option>
<option value="6">128x</option>
</select>
</div>
<div class="setting">
<label for="wb_mode">White Balance Mode:</label>
<select id="wb_mode">
<option value="0">Auto</option>
<option value="1">Sunny</option>
<option value="2">Cloudy</option>
<option value="3">Office</option>
<option value="4">Home</option>
</select>
</div>
<div class="setting">
<label for="whitebal" title="When False, the White Balance Mode setting is used instead.">Auto White Balance:</label>
<input type="checkbox" id="whitebal">
</div>
<div class="setting">
<label for="awb_gain">Auto White Balance Gain:</label>
<input type="checkbox" id="awb_gain">
</div>
<div class="setting">
<label for="gain_ctrl" title="When False, the gain level setting is used instead.">Auto Gain Control:</label>
<input type="checkbox" id="gain_ctrl">
</div>
<div class="setting">
<label for="exposure_ctrl" title="When False, the exposure value setting is used instead.">Auto Exposure Control:</label>
<input type="checkbox" id="exposure_ctrl">
</div>
<div class="setting">
<label for="hmirror">Horizontal Mirror:</label>
<input type="checkbox" id="hmirror">
</div>
<div class="setting">
<label for="vflip">Vertical Flip:</label>
<input type="checkbox" id="vflip">
</div>
<div class="setting">
<label for="lenc" title="This can help compensate for light fall-off at the edge of the sensor area.">Lens Correction:</label>
<input type="checkbox" id="lenc">
</div>
<div class="setting">
<label for="aec2" title="Extends the range of automatic gain control.">Night Mode:</label>
<input type="checkbox" id="aec2">
</div>
<div class="setting">
<label for="dcw" title="When True an advanced white balance mode is selected.">DCW Mode:</label>
<input type="checkbox" id="dcw">
</div>
<div class="setting">
<label for="bpc">Black Point Compensation:</label>
<input type="checkbox" id="bpc">
</div>
<div class="setting">
<label for="wpc">White Point Compensation:</label>
<input type="checkbox" id="wpc">
</div>
<div class="setting">
<label for="raw_gma">Raw Gamma Mode:</label>
<input type="checkbox" id="raw_gma">
</div>
<div class="setting">
<label for="special_effect">Special Effect:</label>
<select id="special_effect">
<option value="0">No effect</option>
<option value="1">Negative</option>
<option value="2">Black and White</option>
<option value="3">Reddish</option>
<option value="4">Greenish</option>
<option value="5">Blue</option>
<option value="6">Retro</option>
</select>
</div>
</div>
<div class="video-container">
<img src="/stream" alt="Loading stream...">
</div>
</div>
</body>
</html>