-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathface_recognition.py
More file actions
26 lines (20 loc) · 811 Bytes
/
face_recognition.py
File metadata and controls
26 lines (20 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import cv2
import face_recognition
def reconocer_caras(imagen_path):
# Cargar la imagen
imagen = face_recognition.load_image_file(imagen_path)
# Encontrar todas las caras en la imagen
ubicaciones = face_recognition.face_locations(imagen)
# Dibujar un rectángulo alrededor de cada cara encontrada
for ubicacion in ubicaciones:
top, right, bottom, left = ubicacion
cv2.rectangle(imagen, (left, top), (right, bottom), (0, 255, 0), 2)
# Mostrar la imagen con las caras resaltadas
cv2.imshow('Caras Reconocidas', imagen)
cv2.waitKey(0)
cv2.destroyAllWindows()
if __name__ == "__main__":
# Ruta de la imagen que deseas analizar
ruta_imagen = 'ruta/a/tu/imagen.jpg'
# Llamar a la función para reconocer caras
reconocer_caras(ruta_imagen)