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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -5
app.py CHANGED
@@ -392,20 +392,42 @@ def js_to_prefere_the_back_camera_of_mobilephones():
392
  # Instanciar o processador
393
  processor = LicensePlateProcessor()
394
 
395
- # Função para ser chamada pelo Gradio
396
- def process_webcam_frame(frame):
397
- return processor.process_frame(frame)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
 
399
  with gr.Blocks(head=js_to_prefere_the_back_camera_of_mobilephones()) as demo:
400
- # with gr.Blocks() as demo:
401
  with gr.Row():
402
  with gr.Column():
403
  input_img = gr.Image(label="Webcam", sources="webcam", streaming=True, mirror_webcam=False)
 
404
  with gr.Column():
405
  output_text = gr.Textbox(label="Últimas 16 Placas Detectadas", lines=20)
 
 
406
  input_img.stream(
407
  process_webcam_frame,
408
- inputs=input_img,
409
  outputs=output_text,
410
  time_limit=None,
411
  stream_every=0.2,
 
392
  # Instanciar o processador
393
  processor = LicensePlateProcessor()
394
 
395
+ # # Função para ser chamada pelo Gradio
396
+ # def process_webcam_frame(frame):
397
+ # return processor.process_frame(frame)
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 = (
404
+ int(original_size[1] * resize_factor),
405
+ int(original_size[0] * resize_factor),
406
+ )
407
+ resized_frame = cv2.resize(frame, new_size, interpolation=cv2.INTER_LINEAR)
408
+
409
+ # Printar as dimensões do frame processado
410
+ print(f"Original frame size: {original_size}, Resized frame size: {new_size}")
411
+
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(
429
  process_webcam_frame,
430
+ inputs=[input_img, resize_factor_input],
431
  outputs=output_text,
432
  time_limit=None,
433
  stream_every=0.2,