coneypo / Dlib_face_recognition_from_camera

Detect and recognize the faces from camera / 调用摄像头进行人脸识别,支持多张人脸同时识别

Home Page:http://www.cnblogs.com/AdaminXie/p/9010298.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

为什么有显卡,速度还是特别慢啊

lilonglilong opened this issue · comments

速度慢是因为对比的时候,对于出现的人脸X,要和数据库里面所有的人脸进行实时的欧式距离计算,是串行的运算,你可以开多个线程并行同时去做 return_euclidean_distance();

不是视频 encode/decode 的 workload 重,是上面说的计算欧式距离运算量大,所以和显卡没关系,如果你是 N 卡,可以用 CUDA 进行加速,要重写代码(原理和多线程一回事),是另一回事了

对于某张人脸,遍历所有存储的人脸特征

                # For every faces detected, compare the faces in the database
                e_distance_list = []
                for i in range(len(features_known_arr)):
                    # 如果 person_X 数据不为空
                    if str(features_known_arr[i][0]) != '0.0':
                        print("with person", str(i + 1), "the e distance: ", end='')
                        e_distance_tmp = return_euclidean_distance(features_cap_arr[k], features_known_arr[i])