logo

人脸识别

2018-05-22 14:52
K
_836317
请在这里粘贴代码# Face recognition with LBP descriptors.
# See Timo Ahonen's "Face Recognition with Local Binary Patterns".
#
# Before running the example:
# 1) Download the AT&T faces database http://www.cl.cam.ac.uk/Research/DTG/attarchive/pub/data/att_faces.zip
# 2) Exract and copy the orl_faces directory to the SD card root.

import sensor, time, image

SUB = "s2"
NUM_SUBJECTS = 5
NUM_SUBJECTS_IMGS = 10

#img = image.Image("/att_faces/%s/xx.bmp"%(SUB)).mask_ellipse()
img = image.Image("/att_faces/%s/1.pgm"%(SUB))# mask_ellipse()在API中并未找到,不用这个并不影响
d0 = img.find_lbp((0, 0, img.width(), img.height())) #从感兴趣的区域提取LBP(本地二进制模式)关键点
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("/att_faces/s%d/xx.bmp"%(s, i)).mask_ellipse()
        img = image.Image("/att_faces/s%d/%d.pgm"%(s, i))
        d1 = img.find_lbp((0, 0, img.width(), img.height()))
        dist += image.match_descriptor(d0, d1)
#对于LBP描述符,该函数返回一个表示整数的整数,两个描述符之间的差异。 然后你可以对此进行阈值/比较距离度量。
#距离是衡量相似度的指标。该越接近0,LBP关键点匹配越好。
    print("Average dist for subject %d: %d"%(s, dist/NUM_SUBJECTS_IMGS))

为什么运行时摄像头闪一下白光,就没反应了?求指教

2018-05-22 15:27
I
网红小智智 星瞳科技

这个程序不是从摄像头里面识别人脸,是从SD卡的已知数据里识别人脸。

你可以在串行终端里看到识别结果。

2018-05-22 15:38
K
_836317

奥奥,是这样啊,那请问有没有摄像头识别人脸的源码

2018-05-22 18:23
I
网红小智智 星瞳科技

真的,分辨人脸,效果不好。