-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f8fb9f
commit be53033
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |