Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -50,6 +50,7 @@ from cryptography.fernet import Fernet
|
|
50 |
import json
|
51 |
import nest_asyncio
|
52 |
from prettytable import PrettyTable
|
|
|
53 |
|
54 |
# Aplicar nest_asyncio para permitir loops de eventos aninhados
|
55 |
nest_asyncio.apply()
|
@@ -62,6 +63,9 @@ def resource_path(relative_path):
|
|
62 |
class LicensePlateProcessor:
|
63 |
def __init__(self):
|
64 |
# Carregar modelo YOLO
|
|
|
|
|
|
|
65 |
model_path = resource_path('best.pt')
|
66 |
self.model = YOLO(model_path, task='detect')
|
67 |
|
@@ -298,6 +302,18 @@ class LicensePlateProcessor:
|
|
298 |
|
299 |
def process_frame(self, frame):
|
300 |
"""Processa um frame individual da webcam."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
302 |
|
303 |
# Detectar placas usando YOLO
|
|
|
50 |
import json
|
51 |
import nest_asyncio
|
52 |
from prettytable import PrettyTable
|
53 |
+
import time
|
54 |
|
55 |
# Aplicar nest_asyncio para permitir loops de eventos aninhados
|
56 |
nest_asyncio.apply()
|
|
|
63 |
class LicensePlateProcessor:
|
64 |
def __init__(self):
|
65 |
# Carregar modelo YOLO
|
66 |
+
self.last_frame_time = None # Armazena o tempo do último frame processado
|
67 |
+
self.fps = 0 # Inicializa o FPS como zero
|
68 |
+
|
69 |
model_path = resource_path('best.pt')
|
70 |
self.model = YOLO(model_path, task='detect')
|
71 |
|
|
|
302 |
|
303 |
def process_frame(self, frame):
|
304 |
"""Processa um frame individual da webcam."""
|
305 |
+
current_time = time.time()
|
306 |
+
|
307 |
+
# Calcula a diferença temporal e o FPS
|
308 |
+
if self.last_frame_time:
|
309 |
+
time_diff = current_time - self.last_frame_time
|
310 |
+
if time_diff > 0: # Evita divisão por zero
|
311 |
+
self.fps = 1 / time_diff
|
312 |
+
|
313 |
+
# Atualiza o tempo do último frame
|
314 |
+
self.last_frame_time = current_time
|
315 |
+
print(f"FPS: {self.fps:.2f}")
|
316 |
+
|
317 |
img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
318 |
|
319 |
# Detectar placas usando YOLO
|