Download index.html from Anm5/ytry: direct link, hf CLI and curl.
- Browser
- Download file 1.65 kB
-
https://huggingface.co/Anm5/ytry/resolve/main/index.html
- Command line
-
hf download hf://Anm5/ytry/index.html
-
curl -L -o index.html https://huggingface.co/Anm5/ytry/resolve/main/index.html
1.65 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Camera Input</title> | |
| </head> | |
| <body> | |
| <h1>Camera Input</h1> | |
| <video id="video" width="640" height="480" autoplay></video> | |
| <button id="captureButton">Capture Frame</button> | |
| <script> | |
| async function setupCamera() { | |
| const video = document.getElementById('video'); | |
| const stream = await navigator.mediaDevices.getUserMedia({ video: true }); | |
| video.srcObject = stream; | |
| } | |
| function captureFrame() { | |
| const video = document.getElementById('video'); | |
| const canvas = document.createElement('canvas'); | |
| canvas.width = video.videoWidth; | |
| canvas.height = video.videoHeight; | |
| const context = canvas.getContext('2d'); | |
| context.drawImage(video, 0, 0, canvas.width, canvas.height); | |
| const frame = canvas.toDataURL('image/jpeg'); | |
| sendFrameToBackend(frame); | |
| } | |
| function sendFrameToBackend(frame) { | |
| fetch('/process_frame', { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| }, | |
| body: JSON.stringify({ frame }) | |
| }) | |
| .then(response => response.json()) | |
| .then(data => console.log(data)) | |
| .catch(error => console.error('Error:', error)); | |
| } | |
| document.getElementById('captureButton').addEventListener('click', captureFrame); | |
| setupCamera(); | |
| </script> | |
| </body> | |
| </html> | |