Update Frontend/scripts.js
Browse files- Frontend/scripts.js +12 -0
Frontend/scripts.js
CHANGED
@@ -36,6 +36,14 @@ function captureAndSend() {
|
|
36 |
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
37 |
const dataUrl = canvas.toDataURL("image/jpeg");
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
fetch("https://prime810-facefeel.hf.space/process_image", {
|
40 |
method: "POST",
|
41 |
headers: { "Content-Type": "application/json" },
|
@@ -53,6 +61,10 @@ function captureAndSend() {
|
|
53 |
const link = document.getElementById("downloadEmoji");
|
54 |
link.href = data.emoji;
|
55 |
link.style.display = "inline-block";
|
|
|
|
|
|
|
|
|
56 |
})
|
57 |
.catch(error => {
|
58 |
console.error("Error:", error);
|
|
|
36 |
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
37 |
const dataUrl = canvas.toDataURL("image/jpeg");
|
38 |
|
39 |
+
// Show captured image preview
|
40 |
+
const previewCanvas = document.getElementById("snapshotCanvas");
|
41 |
+
const previewCtx = previewCanvas.getContext("2d");
|
42 |
+
previewCanvas.width = canvas.width;
|
43 |
+
previewCanvas.height = canvas.height;
|
44 |
+
previewCtx.drawImage(canvas, 0, 0);
|
45 |
+
|
46 |
+
// Send to backend
|
47 |
fetch("https://prime810-facefeel.hf.space/process_image", {
|
48 |
method: "POST",
|
49 |
headers: { "Content-Type": "application/json" },
|
|
|
61 |
const link = document.getElementById("downloadEmoji");
|
62 |
link.href = data.emoji;
|
63 |
link.style.display = "inline-block";
|
64 |
+
|
65 |
+
// Play emoji sound
|
66 |
+
const sound = document.getElementById("emojiSound");
|
67 |
+
if (sound) sound.play();
|
68 |
})
|
69 |
.catch(error => {
|
70 |
console.error("Error:", error);
|