samir-fama commited on
Commit
faf3005
·
verified ·
1 Parent(s): 973f315

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -6
app.py CHANGED
@@ -398,6 +398,8 @@ processor = LicensePlateProcessor()
398
 
399
  # Modificar a função process_webcam_frame
400
  def process_webcam_frame(frame, resize_factor):
 
 
401
  # Redimensionar o frame com o fator fornecido
402
  original_size = frame.shape[:2] # Altura e largura originais
403
  new_size = (
@@ -412,17 +414,28 @@ def process_webcam_frame(frame, resize_factor):
412
  # Processar o frame redimensionado
413
  return processor.process_frame(resized_frame)
414
 
415
- resize_factor = gr.Slider(
416
- minimum=0.1, maximum=3.0, step=0.1, value=1.0, label="Fator de Redimensionamento"
417
- )
418
 
419
  with gr.Blocks(head=js_to_prefere_the_back_camera_of_mobilephones()) as demo:
420
  with gr.Row():
421
  with gr.Column():
422
- input_img = gr.Image(label="Webcam", sources="webcam", streaming=True, mirror_webcam=False)
423
- resize_factor_input = resize_factor
 
 
 
 
 
 
 
424
  with gr.Column():
425
- output_text = gr.Textbox(label="Últimas 16 Placas Detectadas", lines=20)
 
 
 
 
426
 
427
  # Atualizar stream para incluir o novo input
428
  input_img.stream(
 
398
 
399
  # Modificar a função process_webcam_frame
400
  def process_webcam_frame(frame, resize_factor):
401
+ if frame is None:
402
+ return "Frame não detectado"
403
  # Redimensionar o frame com o fator fornecido
404
  original_size = frame.shape[:2] # Altura e largura originais
405
  new_size = (
 
414
  # Processar o frame redimensionado
415
  return processor.process_frame(resized_frame)
416
 
417
+ # resize_factor = gr.Slider(
418
+ # minimum=0.1, maximum=3.0, step=0.1, value=1.0, label="Fator de Redimensionamento"
419
+ # )
420
 
421
  with gr.Blocks(head=js_to_prefere_the_back_camera_of_mobilephones()) as demo:
422
  with gr.Row():
423
  with gr.Column():
424
+ # Criar entrada para webcam
425
+ input_img = gr.Image(
426
+ label="Webcam",
427
+ source="webcam",
428
+ streaming=True,
429
+ mirror_webcam=False
430
+ )
431
+ # Associar o slider ao layout
432
+ resize_factor_input = gr.Slider(minimum=0.1, maximum=3.0, step=0.1, value=1.0, label="Fator de Redimensionamento")
433
  with gr.Column():
434
+ # Caixa de texto para saída
435
+ output_text = gr.Textbox(
436
+ label="Últimas 16 Placas Detectadas",
437
+ lines=20
438
+ )
439
 
440
  # Atualizar stream para incluir o novo input
441
  input_img.stream(