Spaces:
Configuration error
Configuration error
| import numpy as np | |
| import cv2 | |
| def mostrar_imagen(imagen): | |
| return imagen | |
| def analisis_facial(imagen): | |
| img = np.array(imagen) | |
| gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) | |
| detector = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml") | |
| faces = detector.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5) | |
| for (x, y, w, h) in faces: | |
| cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2) | |
| if len(faces) == 0: | |
| return img, "No se detectaron rostros." | |
| else: | |
| return img, f"Se detectaron {len(faces)} rostro(s)." | |