Spaces:
Runtime error
Runtime error
HuggingFace-SK
commited on
Commit
·
40b5f21
1
Parent(s):
f9f6898
add dynamic wrapper height
Browse files
templates/browser-detect.html
CHANGED
|
@@ -28,7 +28,7 @@
|
|
| 28 |
|
| 29 |
<div class="container">
|
| 30 |
<video id="webcam" style="display:none" autoplay="" playsinline=""></video>
|
| 31 |
-
<div class="canvas_wrapper">
|
| 32 |
<canvas class="output_canvas" id="output_canvas" width="100%" height="300%"></canvas>
|
| 33 |
<center>
|
| 34 |
<button id="webcamButton">
|
|
@@ -104,6 +104,7 @@ function set_output_array(text) {
|
|
| 104 |
let webcamRunning = false;
|
| 105 |
var time_since_letter = 0
|
| 106 |
var last_letter_time = 0
|
|
|
|
| 107 |
// Before we can use HandLandmarker class we must wait for it to finish
|
| 108 |
// loading. Machine Learning models can be large and take a moment to
|
| 109 |
// get everything needed to run.
|
|
@@ -156,6 +157,7 @@ function set_output_array(text) {
|
|
| 156 |
else {
|
| 157 |
webcamRunning = true;
|
| 158 |
enableWebcamButton.style = "display:none"
|
|
|
|
| 159 |
}
|
| 160 |
// getUsermedia parameters.
|
| 161 |
const constraints = {
|
|
@@ -185,6 +187,13 @@ function set_output_array(text) {
|
|
| 185 |
canvasCtx.save();
|
| 186 |
canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
|
| 187 |
canvasCtx.drawImage(video, 0, 0, canvasElement.width, (video.videoHeight / video.videoWidth) * canvasElement.width)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
if (results.landmarks && results.handednesses[0]) {
|
| 190 |
var current_time = Math.round(Date.now())
|
|
|
|
| 28 |
|
| 29 |
<div class="container">
|
| 30 |
<video id="webcam" style="display:none" autoplay="" playsinline=""></video>
|
| 31 |
+
<div class="canvas_wrapper" id="canvas_wrapper">
|
| 32 |
<canvas class="output_canvas" id="output_canvas" width="100%" height="300%"></canvas>
|
| 33 |
<center>
|
| 34 |
<button id="webcamButton">
|
|
|
|
| 104 |
let webcamRunning = false;
|
| 105 |
var time_since_letter = 0
|
| 106 |
var last_letter_time = 0
|
| 107 |
+
var is_first_run=1
|
| 108 |
// Before we can use HandLandmarker class we must wait for it to finish
|
| 109 |
// loading. Machine Learning models can be large and take a moment to
|
| 110 |
// get everything needed to run.
|
|
|
|
| 157 |
else {
|
| 158 |
webcamRunning = true;
|
| 159 |
enableWebcamButton.style = "display:none"
|
| 160 |
+
|
| 161 |
}
|
| 162 |
// getUsermedia parameters.
|
| 163 |
const constraints = {
|
|
|
|
| 187 |
canvasCtx.save();
|
| 188 |
canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
|
| 189 |
canvasCtx.drawImage(video, 0, 0, canvasElement.width, (video.videoHeight / video.videoWidth) * canvasElement.width)
|
| 190 |
+
if (is_first_run == 1){
|
| 191 |
+
var elem_rect = document.getElementById("output_canvas").getBoundingClientRect()
|
| 192 |
+
console.log(elem_rect.height | 0);
|
| 193 |
+
document.getElementById("canvas_wrapper").style.height = (elem_rect.height | 0).toString()+"px"
|
| 194 |
+
|
| 195 |
+
is_first_run=0
|
| 196 |
+
}
|
| 197 |
|
| 198 |
if (results.landmarks && results.handednesses[0]) {
|
| 199 |
var current_time = Math.round(Date.now())
|