Spaces:
Runtime error
Runtime error
HuggingFace-SK
commited on
Commit
·
33d277b
1
Parent(s):
17c3f55
style flip camera btn
Browse files- templates/browser-detect.html +14 -11
templates/browser-detect.html
CHANGED
|
@@ -27,8 +27,13 @@
|
|
| 27 |
|
| 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">
|
|
@@ -47,9 +52,7 @@
|
|
| 47 |
<button id="text-to-speech" onclick="speak(document.getElementById('text').value)">
|
| 48 |
<span>Listen to the text 🔊</span>
|
| 49 |
</button>
|
| 50 |
-
|
| 51 |
-
<span>Switch CM</span>
|
| 52 |
-
</button>
|
| 53 |
</div>
|
| 54 |
<center>
|
| 55 |
<script>
|
|
@@ -149,18 +152,18 @@
|
|
| 149 |
else {
|
| 150 |
console.warn("getUserMedia() is not supported by your browser");
|
| 151 |
}
|
| 152 |
-
async function switch_camera(){
|
| 153 |
-
if (video_facing_mode=='user'){
|
| 154 |
-
webcamRunning= false
|
| 155 |
video_facing_mode = 'environment'
|
| 156 |
await load_camera()
|
| 157 |
-
webcamRunning= true
|
| 158 |
}
|
| 159 |
-
else{
|
| 160 |
webcamRunning = false
|
| 161 |
video_facing_mode = 'user'
|
| 162 |
await load_camera()
|
| 163 |
-
webcamRunning= true
|
| 164 |
}
|
| 165 |
}
|
| 166 |
// Enable the live webcam view and start detection.
|
|
@@ -181,7 +184,7 @@
|
|
| 181 |
// getUsermedia parameters.
|
| 182 |
load_camera()
|
| 183 |
}
|
| 184 |
-
function load_camera(){
|
| 185 |
const constraints = {
|
| 186 |
video: {
|
| 187 |
facingMode: video_facing_mode
|
|
@@ -197,7 +200,7 @@
|
|
| 197 |
let results = undefined;
|
| 198 |
console.log(video);
|
| 199 |
async function predictWebcam() {
|
| 200 |
-
if (video.videoHeight == 0){
|
| 201 |
return
|
| 202 |
}
|
| 203 |
canvasElement.width = window.innerWidth;
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
<div class="container">
|
| 30 |
+
|
| 31 |
<video id="webcam" style="display:none" autoplay="" playsinline=""></video>
|
| 32 |
<div class="canvas_wrapper" id="canvas_wrapper">
|
| 33 |
+
<button id="switch-camera" style="position: absolute; top:10px; left:10px; padding:5px; height:40px; width:40px; text-align: center; border-radius: 12.25px; font-size: 20px; font-weight: 900; border:none; background-color: #f2f2f2;
|
| 34 |
+
box-shadow: 0px 4px 20px 4px rgba(0, 0, 0, 0.38); z-index:100">
|
| 35 |
+
<span>⟳</span>
|
| 36 |
+
</button>
|
| 37 |
<canvas class="output_canvas" id="output_canvas" width="100%" height="300%"></canvas>
|
| 38 |
<center>
|
| 39 |
<button id="webcamButton">
|
|
|
|
| 52 |
<button id="text-to-speech" onclick="speak(document.getElementById('text').value)">
|
| 53 |
<span>Listen to the text 🔊</span>
|
| 54 |
</button>
|
| 55 |
+
|
|
|
|
|
|
|
| 56 |
</div>
|
| 57 |
<center>
|
| 58 |
<script>
|
|
|
|
| 152 |
else {
|
| 153 |
console.warn("getUserMedia() is not supported by your browser");
|
| 154 |
}
|
| 155 |
+
async function switch_camera() {
|
| 156 |
+
if (video_facing_mode == 'user') {
|
| 157 |
+
webcamRunning = false
|
| 158 |
video_facing_mode = 'environment'
|
| 159 |
await load_camera()
|
| 160 |
+
webcamRunning = true
|
| 161 |
}
|
| 162 |
+
else {
|
| 163 |
webcamRunning = false
|
| 164 |
video_facing_mode = 'user'
|
| 165 |
await load_camera()
|
| 166 |
+
webcamRunning = true
|
| 167 |
}
|
| 168 |
}
|
| 169 |
// Enable the live webcam view and start detection.
|
|
|
|
| 184 |
// getUsermedia parameters.
|
| 185 |
load_camera()
|
| 186 |
}
|
| 187 |
+
function load_camera() {
|
| 188 |
const constraints = {
|
| 189 |
video: {
|
| 190 |
facingMode: video_facing_mode
|
|
|
|
| 200 |
let results = undefined;
|
| 201 |
console.log(video);
|
| 202 |
async function predictWebcam() {
|
| 203 |
+
if (video.videoHeight == 0) {
|
| 204 |
return
|
| 205 |
}
|
| 206 |
canvasElement.width = window.innerWidth;
|