|
<!DOCTYPE html> |
|
<html lang="en"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
<title>Let's Guess That Pose</title> |
|
<style> |
|
body { |
|
background-color: #000; |
|
display: flex; |
|
flex-direction: column; |
|
align-items: center; |
|
justify-content: center; |
|
height: 100vh; |
|
margin: 0; |
|
} |
|
|
|
h1 { |
|
font-family: 'Comic Sans MS', cursive, sans-serif; |
|
color: #FF69B4; |
|
font-size: 72px; |
|
text-align: center; |
|
margin-bottom: 20px; |
|
} |
|
|
|
button { |
|
font-size: 24px; |
|
background-color: #FF0066; |
|
color: white; |
|
padding: 10px 20px; |
|
border: none; |
|
border-radius: 5px; |
|
cursor: pointer; |
|
transition: background-color 0.3s; |
|
} |
|
|
|
button:hover { |
|
background-color: #E6005C; |
|
} |
|
|
|
#main-container { |
|
color:white; |
|
display: flex; |
|
align-items: flex-start; |
|
justify-content: center; |
|
margin-top: 20px; |
|
width: 100%; |
|
} |
|
|
|
#buttons-container { |
|
display: flex; |
|
justify-content: center; |
|
margin-bottom: 20px; |
|
align-items: center; |
|
} |
|
|
|
#video-container, |
|
#modified-image-container { |
|
margin: 0 20px; |
|
} |
|
#video-container video{ |
|
width: 100%; |
|
height: 100%; |
|
} |
|
|
|
#video-container video, |
|
#modified-image-container img { |
|
height: auto; |
|
display: block; |
|
margin-bottom: 10px; |
|
} |
|
#modified-image-container img{ |
|
width: 400px; |
|
} |
|
|
|
#countdown { |
|
font-size: 48px; |
|
color: pink; |
|
display: none; |
|
} |
|
.switch { |
|
position: relative; |
|
display: inline-block; |
|
width: 60px; |
|
height: 34px; |
|
} |
|
|
|
|
|
.switch input { |
|
opacity: 0; |
|
width: 0; |
|
height: 0; |
|
} |
|
|
|
|
|
.slider { |
|
position: absolute; |
|
cursor: pointer; |
|
top: 0; |
|
left: 0; |
|
right: 0; |
|
bottom: 0; |
|
background-color: #ccc; |
|
transition: .4s; |
|
border-radius: 34px; |
|
} |
|
|
|
.slider:before { |
|
position: absolute; |
|
content: ""; |
|
height: 26px; |
|
width: 26px; |
|
left: 4px; |
|
bottom: 4px; |
|
background-color: white; |
|
transition: .4s; |
|
border-radius: 50%; |
|
} |
|
|
|
input:checked + .slider { |
|
background-color: #2196F3; |
|
} |
|
|
|
input:focus + .slider { |
|
box-shadow: 0 0 1px #2196F3; |
|
} |
|
|
|
input:checked + .slider:before { |
|
transform: translateX(26px); |
|
} |
|
|
|
|
|
.slider.round { |
|
border-radius: 34px; |
|
} |
|
|
|
.slider.round:before { |
|
border-radius: 50%; |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<h1>Let's Guess That Pose</h1> |
|
<div id ="buttons-container"> |
|
<button id="start">Start</button> |
|
<label class="switch"> |
|
<input type="checkbox" id = "model-toggle" onchange="toggleCheckbox()"> |
|
<span class="slider round"></span> |
|
</label> |
|
</div> |
|
<div id="main-container"> |
|
<div id="video-container"> |
|
<video width="800" height="800" id="video" autoplay></video> |
|
<canvas width="800" height="800" id="canvas" style="display:none;"></canvas> |
|
<div id="countdown">10</div> |
|
</div> |
|
<div id="modified-image-container"> |
|
<img id="modifiedImage" src="https://steamuserimages-a.akamaihd.net/ugc/936063271541499414/3C62E6915EF2AB9EEBF6712CC4E230CE43CC04B5/?imw=1024&imh=1024&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=true" alt="Original Image"> |
|
<div id="guess"></div> |
|
</div> |
|
|
|
</div> |
|
<script> |
|
const video = document.getElementById('video'); |
|
const canvas = document.getElementById('canvas'); |
|
const startButton = document.getElementById('start'); |
|
const countdownElement = document.getElementById('countdown'); |
|
const guessElement = document.getElementById('guess'); |
|
const keypointImage = document.getElementById('modifiedImage'); |
|
|
|
let countdown = 10; |
|
let useModelGAN = false; |
|
let imageID = 0; |
|
|
|
|
|
navigator.mediaDevices.getUserMedia({ video: true }) |
|
.then((stream) => { |
|
video.srcObject = stream; |
|
}) |
|
.catch((err) => { |
|
console.error('Error accessing the camera: ', err); |
|
}); |
|
|
|
function captureImage() { |
|
const context = canvas.getContext('2d'); |
|
context.drawImage(video, 0, 0, canvas.width, canvas.height); |
|
const imageData = canvas.toDataURL('image/png'); |
|
|
|
|
|
fetch('https://ddnb338-lumos-app.hf.space/upload', { |
|
method: 'POST', |
|
body: JSON.stringify({ image_data: imageData, use_model_gan: useModelGAN, unique_ID: imageID }), |
|
headers: { |
|
'Content-Type': 'application/json' |
|
} |
|
}) |
|
.then(response => response.text()) |
|
.then(data => { |
|
|
|
|
|
|
|
keypointImage.src = `static/keypoint_image_${imageID}.jpg`; |
|
guessElement.textContent = `Prediction: ${data}`; |
|
}) |
|
.catch(error => console.error('Error sending image data: ', error)); |
|
} |
|
|
|
function startCountdown() { |
|
countdownElement.style.display = 'block'; |
|
if (countdown > 0) { |
|
countdownElement.textContent = countdown; |
|
setTimeout(startCountdown, 1000); |
|
countdown--; |
|
} else { |
|
captureImage(); |
|
countdown = 5; |
|
countdownElement.style.display = 'none'; |
|
} |
|
} |
|
|
|
function toggleCheckbox() { |
|
useModelGAN = document.getElementById('model-toggle').checked; |
|
} |
|
|
|
startButton.addEventListener('click', () => { |
|
keypointImage.src = 'https://steamuserimages-a.akamaihd.net/ugc/936063271541499414/3C62E6915EF2AB9EEBF6712CC4E230CE43CC04B5/?imw=1024&imh=1024&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=true'; |
|
guessElement.textContent = ''; |
|
startCountdown(); |
|
imageID++; |
|
}); |
|
</script> |
|
</body> |
|
</html> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|