face_recognition.py

# Esta obra está licenciada bajo la licencia MIT.
# Copyright (c) 2013-2023 OpenMV LLC. Todos los derechos reservados.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Reconocimiento facial con descriptores LBP.
# Ver "Face Recognition with Local Binary Patterns" de Timo Ahonen.
#
# Antes de ejecutar el ejemplo:
# 1) Descarga la base de datos de rostros AT&T http://www.cl.cam.ac.uk/Research/DTG/attarchive/pub/data/att_faces.zip
# 2) Extrae y copia el directorio orl_faces a la raíz de la tarjeta SD.
#
# NOTA: Esto es solo una implementación PoC del artículo mencionado arriba; no funciona bien en condiciones reales.

import image

SUB = "s2"
NUM_SUBJECTS = 5
NUM_SUBJECTS_IMGS = 10

img = image.Image("orl_faces/%s/1.pgm" % (SUB)).mask_ellipse()
d0 = img.find_lbp(roi=(0, 0, img.width(), img.height()))
img = None

print("")
for s in range(1, NUM_SUBJECTS + 1):
    dist = 0
    for i in range(2, NUM_SUBJECTS_IMGS + 1):
        img = image.Image("orl_faces/s%d/%d.pgm" % (s, i)).mask_ellipse()
        d1 = img.find_lbp(roi=(0, 0, img.width(), img.height()))
        dist += image.match_descriptor(d0, d1)
    print("Average dist for subject %d: %d" % (s, dist / NUM_SUBJECTS_IMGS))

results matching ""

    No results matching ""