srivatsavdamaraju commited on
Commit
2328c21
·
verified ·
1 Parent(s): ef0f86a

Create templates/depthmap.html

Browse files
Files changed (1) hide show
  1. templates/depthmap.html +49 -0
templates/depthmap.html ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- templates/index.html -->
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Webcam Stream</title>
8
+ </head>
9
+ <body>
10
+ <h1>Webcam Stream</h1>
11
+ <video id="video" width="640" height="480" autoplay></video>
12
+ <img id="output" src="" alt="Processed Frame" />
13
+ <script>
14
+ const video = document.getElementById('video');
15
+ const output = document.getElementById('output');
16
+
17
+ // Access the webcam
18
+ navigator.mediaDevices.getUserMedia({ video: true })
19
+ .then(stream => {
20
+ video.srcObject = stream;
21
+
22
+ setInterval(() => {
23
+ const canvas = document.createElement('canvas');
24
+ canvas.width = 640;
25
+ canvas.height = 480;
26
+ const ctx = canvas.getContext('2d');
27
+ ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
28
+ canvas.toBlob(blob => {
29
+ const formData = new FormData();
30
+ formData.append('frame', blob, 'frame.jpg');
31
+
32
+ // Send the frame to the Flask server
33
+ fetch('/video_feed', {
34
+ method: 'POST',
35
+ body: formData
36
+ })
37
+ .then(response => response.blob())
38
+ .then(imageBlob => {
39
+ output.src = URL.createObjectURL(imageBlob);
40
+ });
41
+ }, 'image/jpeg', 0.95);
42
+ }, 100); // Send every 100ms
43
+ })
44
+ .catch(error => {
45
+ console.error("Error accessing webcam: ", error);
46
+ });
47
+ </script>
48
+ </body>
49
+ </html>