# Leer de imágenes import face_recognition import cv2 # Cargar imagen conocida imagen_conocida = face_recognition.load_image_file ("cord.png") encoding_conocido = face_recognition.face_encodings ( imagen_conocida )[0] # Capturar video de la webcam video = cv2.VideoCapture(0) while True: ret , frame = video.read () if not ret : break # Detectar rostros en el frame ubicaciones = face_recognition.face_locations ( frame ) codificaciones = face_recognition.face_encodings ( frame , ubicaciones) for (top, right , bottom, left ), cod in zip(ubicaciones, codificaciones): # Comparar con el rostro conocido coincidencias = face_recognition.compare_faces ([ encoding_conocido ], cod ) nombre = "Hola Desconocido" if coincidencias[0]: nombre = "Hola ordova " # Dibujar rectángulo y nombre cv2.rectangle( frame , ( left , top), ( right , bottom), (0, 255, 0), 2) cv2.putText( frame , nombre, ( left , top - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2) cv2.imshow("Reconocimiento facial", frame ) if cv2.waitKey(1) & 0xFF == ord ('q'): break video.release () cv2.destroyAllWindows() PF reconocimiento facial