add websocket counter plate
This commit is contained in:
@@ -57,10 +57,24 @@ def save_plate_capture(plate_number, full_frame):
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
|
||||
# Solo guardar frame completo
|
||||
filename = f"{DATASET_DIR}/{plate_number}_{timestamp}.jpg"
|
||||
cv2.imwrite(filename, full_frame, [cv2.IMWRITE_JPEG_QUALITY, 95])
|
||||
filename = f"{plate_number}_{timestamp}.jpg"
|
||||
filepath = f"{DATASET_DIR}/{filename}"
|
||||
cv2.imwrite(filepath, full_frame, [cv2.IMWRITE_JPEG_QUALITY, 95])
|
||||
|
||||
print(f"📸 Saved to dataset: {plate_number}")
|
||||
# Contar total de capturas
|
||||
total_count = len([f for f in os.listdir(DATASET_DIR) if f.endswith('.jpg')])
|
||||
|
||||
# Notificar al backend para WebSocket
|
||||
try:
|
||||
requests.post(f"{BACKEND_URL}/api/dataset/capture", json={
|
||||
'plate_number': plate_number,
|
||||
'filename': filename,
|
||||
'count': total_count
|
||||
}, timeout=2)
|
||||
except:
|
||||
pass # No bloquear si falla la notificación
|
||||
|
||||
print(f"📸 Saved to dataset: {plate_number} (Total: {total_count})")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"❌ Error saving capture: {e}")
|
||||
|
||||
Reference in New Issue
Block a user