File size: 7,937 Bytes
f31c85a 1ed4248 f31c85a b6cf4b8 f31c85a 6fce848 f31c85a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
<!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; /* Pink */
font-size: 72px; /* Bigger font size */
text-align: center; /* Center align */
margin-bottom: 20px; /* Some spacing under the title */
}
button {
font-size: 24px; /* Adjust button font size */
background-color: #FF0066; /* Dark pink background color */
color: white; /* White lettering */
padding: 10px 20px; /* Padding for the button */
border: none; /* Remove border */
border-radius: 5px; /* Add border radius */
cursor: pointer; /* Change cursor on hover */
transition: background-color 0.3s; /* Smooth transition */
}
button:hover {
background-color: #E6005C; /* Darker pink on hover */
}
#main-container {
color:white;
display: flex; /* Use flexbox layout */
align-items: flex-start; /* Align items at the start of the container */
justify-content: center; /* Center align child elements horizontally */
margin-top: 20px; /* Add margin space */
width: 100%;
}
#buttons-container {
display: flex; /* Use flexbox layout */
justify-content: center; /* Center child elements horizontally */
margin-bottom: 20px; /* Add margin at the bottom */
align-items: center;
}
#video-container,
#modified-image-container {
margin: 0 20px; /* Add horizontal margin space */
}
#video-container video{
width: 100%; /* Ensure the video fills its container */
height: 100%;
}
#video-container video,
#modified-image-container img {
height: auto; /* Maintain aspect ratio */
display: block; /* Ensure images fill their container */
margin-bottom: 10px; /* Add space between the video and the image */
}
#modified-image-container img{
width: 400px;
}
#countdown {
font-size: 48px;
color: pink;
display: none; /* Initially hide the countdown */
}
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.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);
}
/* Rounded sliders */
.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;
// Access the camera
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');
// Send image data to Flask route for processing
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 => {
//if (data != 'No keypoints detected'){
//keypointImage.src = `static/keypoint_image_${imageID}.jpg`;
// }
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'; // Show the countdown
if (countdown > 0) {
countdownElement.textContent = countdown;
setTimeout(startCountdown, 1000); //will call startCountdown again after 1000 milliseconds
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>
|