samir-fama commited on
Commit
e933861
·
verified ·
1 Parent(s): 9d56038

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -358,6 +358,21 @@ class LicensePlateProcessor:
358
  # PLAY GRADIO
359
  #===========================================================================#
360
  #===========================================================================#
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  # Instanciar o processador
362
  processor = LicensePlateProcessor()
363
 
@@ -365,8 +380,8 @@ processor = LicensePlateProcessor()
365
  def process_webcam_frame(frame):
366
  return processor.process_frame(frame)
367
 
368
-
369
- with gr.Blocks() as demo:
370
  with gr.Row():
371
  with gr.Column():
372
  input_img = gr.Image(label="Webcam", sources="webcam", streaming=True, mirror_webcam=False)
 
358
  # PLAY GRADIO
359
  #===========================================================================#
360
  #===========================================================================#
361
+ def js_to_prefere_the_back_camera_of_mobilephones():
362
+ custom_html = """
363
+ <script>
364
+ const originalGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
365
+
366
+ navigator.mediaDevices.getUserMedia = (constraints) => {
367
+ if (!constraints.video.facingMode) {
368
+ constraints.video.facingMode = {ideal: "environment"};
369
+ }
370
+ return originalGetUserMedia(constraints);
371
+ };
372
+ </script>
373
+ """
374
+ return custom_html
375
+
376
  # Instanciar o processador
377
  processor = LicensePlateProcessor()
378
 
 
380
  def process_webcam_frame(frame):
381
  return processor.process_frame(frame)
382
 
383
+ with gr.Blocks(head=js_to_prefere_the_back_camera_of_mobilephones()) as demo
384
+ # with gr.Blocks() as demo:
385
  with gr.Row():
386
  with gr.Column():
387
  input_img = gr.Image(label="Webcam", sources="webcam", streaming=True, mirror_webcam=False)