-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.html
58 lines (56 loc) · 2.05 KB
/
test.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YOLOv8 Detection</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
padding: 20px;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
#video {
width: 100%;
max-width: 800px;
height: auto;
border: 1px solid #ccc;
display: block;
margin: 20px auto; /* Center the video feed */
}
</style>
</head>
<body>
<h1>YOLOv8 Object Detection</h1>
<button id="startButton">Start YOLO</button>
<button id="stopButton" disabled>Stop YOLO</button>
<img id="video" src="" alt="Video Feed" />
<script>
document.getElementById('startButton').onclick = function() {
fetch('/start')
.then(response => {
if (!response.ok) throw new Error('Network response was not ok');
document.getElementById('video').src = '/video_feed'; // Start the video feed
this.disabled = true; // Disable the start button
document.getElementById('stopButton').disabled = false; // Enable the stop button
})
.catch(error => console.error('Error:', error));
};
document.getElementById('stopButton').onclick = function() {
fetch('/stop')
.then(response => {
if (!response.ok) throw new Error('Network response was not ok');
document.getElementById('video').src = ''; // Stop the video feed
this.disabled = true; // Disable the stop button
document.getElementById('startButton').disabled = false; // Enable the start button
})
.catch(error => console.error('Error:', error));
};
</script>
</body>
</html>