test / index.html
Piarasingh85's picture
Create index.html
e2d94bd verified
raw
history blame contribute delete
959 Bytes
<!DOCTYPE html>
<html>
<head>
<title>Live Feed with Hugging Face</title>
</head>
<body>
<video id="video" width="640" height="480" autoplay></video>
<script>
const video = document.getElementById('video');
const ws = new WebSocket("ws://localhost:8000/ws");
ws.onmessage = function(event) {
const predictions = JSON.parse(event.data);
console.log(predictions);
// Process predictions to draw bounding boxes, etc.
};
// This part is to display the live video feed
if (navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({ video: true })
.then(function(stream) {
video.srcObject = stream;
})
.catch(function(error) {
console.log("Something went wrong!");
});
}
</script>
</body>
</html>