-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathregional_master.html
52 lines (50 loc) · 1.8 KB
/
regional_master.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
<!DOCTYPE html>
<html>
<head>
<title>Local Master - Live Stream</title>
<style>
#video { width: 640px; height: 480px; }
#detections { margin-top: 10px; }
#notifications { color: red; }
</style>
</head>
<body>
<h1>Local Master - Live Stream</h1>
<img id="video" src="" alt="Live Stream">
<div id="detections"></div>
<div id="notifications"></div>
<button id="acknowledge-button" style="display: none;">Acknowledge Threat</button>
<script>
const ws = new WebSocket('ws://localhost:8765/local_master');
const acknowledgeButton = document.getElementById('acknowledge-button');
const detectionsDiv = document.getElementById('detections');
const notificationsDiv = document.getElementById('notifications');
ws.onmessage = function(event) {
const data = JSON.parse(event.data);
if (data.frame) {
document.getElementById('video').src = 'data:image/jpeg;base64,' + data.frame;
}
if (data.detections) {
detectionsDiv.innerHTML = '<h3>Detections:</h3>';
data.detections.forEach(detection => {
detectionsDiv.innerHTML += <p>${detection.class} - ${detection.confidence.toFixed(2)}</p>;
});
}
if (data.threat_detected) {
acknowledgeButton.style.display = 'block';
notificationsDiv.textContent = 'Threat detected! Please acknowledge.';
// Play alarm
new Audio('alarm.mp3').play(); // Replace with path to your alarm sound file
} else {
acknowledgeButton.style.display = 'none';
notificationsDiv.textContent = '';
}
};
acknowledgeButton.onclick = function() {
ws.send('acknowledge');
acknowledgeButton.style.display = 'none';
notificationsDiv.textContent = 'Threat acknowledged.';
};
</script>
</body>
</html>