Spaces:
Configuration error
Configuration error
File size: 603 Bytes
6f89cdc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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)."
|