16 lines
457 B
Python
16 lines
457 B
Python
from ultralytics import YOLO
|
|
|
|
|
|
class DetectorPersona:
|
|
def __init__(self, modelo="yolov8n.pt", confianza=0.5):
|
|
self.model = YOLO(modelo)
|
|
self.confianza = confianza
|
|
|
|
def hay_persona(self, frame) -> bool:
|
|
resultados = self.model.predict(frame, verbose=False, conf=self.confianza)
|
|
for r in resultados:
|
|
for c in r.boxes.cls:
|
|
if int(c) == 0:
|
|
return True
|
|
return False
|