Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaJaiswal77 authored Sep 1, 2023
1 parent 8f8fb9f commit be53033
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
28 changes: 28 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const video = document.getElementById('video');
const canvas = document.getElementById('virtualTryOnCanvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

const socket = io.connect('http://localhost:5000'); // Update the URL if needed

let currentGlasses = 1; // Initialize with the default glasses image
const startVideo = async () => {
try {
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
video.srcObject = stream;
} catch (error) {
console.error('Error accessing webcam:', error);
}
};

startVideo();

socket.on('frame', (frame) => {
const img = new Image();
img.src = 'data:image/jpeg;base64,' + frame;
img.onload = () => {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
};
});
11 changes: 11 additions & 0 deletions success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>image uploaded</h1>
</body>
</html>

0 comments on commit be53033

Please sign in to comment.