2 Commits

Author SHA1 Message Date
9f6e50ca4c Main filename refactor 2026-01-22 19:54:05 +01:00
694ccc0edb feature: Add GNU/Linux and MacOS support 2026-01-22 19:48:42 +01:00
2 changed files with 19 additions and 8 deletions

View File

@@ -14,11 +14,13 @@ import time
import math
import numpy as np
import json
import platform
import sys
# ===========================
# CONFIGURACIÓN
# ===========================
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# Modelos
MODEL_PERSON_PATH = os.path.join(BASE_DIR, 'models', 'yolov8n.pt') # Revertido a Nano por velocidad
@@ -45,6 +47,15 @@ BG_COLOR = "#282c34"
TEXT_COLOR = "#abb2bf"
ACCENT_COLOR = "#61afef"
# Cross-platform video backend
V_BACKEND = cv2.CAP_ANY
if platform.system() == "Windows":
V_BACKEND = cv2.CAP_DSHOW
elif platform.system() == "Darwin": # macOS
V_BACKEND = cv2.CAP_AVFOUNDATION
elif platform.system() == "Linux":
V_BACKEND = cv2.CAP_V4L2
# ===========================
# CLASES DE UTILIDAD
# ===========================
@@ -550,12 +561,12 @@ class App:
self.btn_graph = tk.Button(self.controls_frame, text="Generar Gráfico", command=generate_graph, bg="#98c379", fg="black", font=("Helvetica", 10))
self.btn_graph.pack(side="left", padx=5)
self.log_text = scrolledtext.ScrolledText(window, height=8, bg="#21252b", fg="white", font=("Consolas", 9))
self.log_text = scrolledtext.ScrolledText(window, height=8, bg="#21252b", fg="white", font=("Courier", 9) if platform.system() != "Windows" else ("Consolas", 9))
self.log_text.pack(fill="x", padx=10, pady=5)
# Logic
# Usamos CAP_DSHOW en Windows para compatibilidad "Universal" (Mejor acceso a ajustes)
self.cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
# Usamos el backend apropiado según el sistema operativo
self.cap = cv2.VideoCapture(0, V_BACKEND)
# Configurar 1080p por defecto
self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
@@ -830,8 +841,8 @@ class App:
if self.cap.isOpened():
self.cap.release()
# Reabrir con DirectShow para mantener compatibilidad universal
self.cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
# Reabrir con el backend apropiado
self.cap = cv2.VideoCapture(0, V_BACKEND)
self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
@@ -1012,7 +1023,7 @@ class App:
try:
if self.cap.isOpened():
self.cap.release()
self.cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
self.cap = cv2.VideoCapture(0, V_BACKEND)
self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
except:

View File

@@ -18,7 +18,7 @@
]
],
"calibration": {
"active": false,
"active": true,
"points": [
[
76,