人脸识别检测系统 python 深度学习 YOLOv5 计算机毕业设计(包含文档+源码+部署教程)
人脸识别检测系统 python 深度学习 YOLOv5 计算机毕业设计(包含文档+源码+部署教程)
[毕业设计]2023-2024年最新最全计算机专业毕设选题推荐汇总
感兴趣的可以先收藏起来,还有大家在毕设选题,项目以及论文编写等相关问题都可以给我留言咨询,希望帮助更多的人 。
1、项目介绍
系统实现了集识别人脸、录入人脸、管理人脸在内的多项功能:包括通过选择人脸图片、视频、摄像头进行已录入人脸的实时识别;可通过图片和摄像头检测人脸并录入新的人脸;通过系统管理和更新人脸数据等功能,检测速度快、识别精度较高。
2、项目界面
(1)人脸识别首页
(2)人脸识别数据管理界面
(3)人脸识别检测

(4)摄像头检测识别
3、项目说明
人脸检测与识别是机器视觉领域最热门的研究方向之一,本文详细介绍博主自主设计的一款基于深度学习的人脸识别与管理系统。博文给出人脸识别实现原理的同时,给出Python的人脸识别实现代码以及PyQt设计的UI界面。系统实现了集识别人脸、录入人脸、管理人脸在内的多项功能:包括通过选择人脸图片、视频、摄像头进行已录入人脸的实时识别;可通过图片和摄像头检测人脸并录入新的人脸;通过系统管理和更新人脸数据等功能,检测速度快、识别精度较高。
近年来,人脸识别的技术愈发成熟,在大型数据集上的训练测试结果已超过人类,其应用也日益广泛,譬如刷脸支付、安防侦破、出入口控制、互联网服务等。人脸识别(Face Recognition)是一种通过获取人面部的特征信息进行身份确认的技术,类似已用于身份识别的人体的其他生物特征(如虹膜、指纹等),人脸具备唯一性、一致性和高度的不可复制性,为身份识别提供了稳定的条件。人脸识别系统是博主一直想做的一个项目,通过人脸面部信息识别可以进行很多有趣的设计,如面部解锁、考勤打卡等。
4、核心代码
# 人脸识别与管理系统:本程序用于图片、视频及摄像头中人脸识别
import os
import time
import warnings
import cv2
import dlib
import numpy as np
import pandas as pd
from PIL import Image, ImageDraw, ImageFont
# 忽略警告
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
warnings.filterwarnings(action='ignore')
fontC = ImageFont.truetype("./FaceRecUI/Font/platech.ttf", 14, 0)
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor('./data/data_dlib/shape_predictor_68_face_landmarks.dat')
face_reco_model = dlib.face_recognition_model_v1("./data/data_dlib"
"/dlib_face_recognition_resnet_model_v1.dat")
def euclidean_distance(feature_1, feature_2):
# 计算两个128D向量间的欧式距离
feature_1 = np.array(feature_1)
feature_2 = np.array(feature_2)
dist = np.sqrt(np.sum(np.square(feature_1 - feature_2)))
return dist
def drawRectBox(img, rect_pos, addText):
cv2.rectangle(img, (int(round(rect_pos[0])), int(round(rect_pos[1]))),
(int(round(rect_pos[2])), int(round(rect_pos[3]))),
(0, 0, 255), 2)
cv2.rectangle(img, (int(rect_pos[0] - 1), int(rect_pos[1]) - 16), (int(rect_pos[0] + 75), int(rect_pos[1])), (0, 0, 255), -1,
cv2.LINE_AA)
img = Image.fromarray(img)
draw = ImageDraw.Draw(img)
draw.text((int(rect_pos[0] + 1), int(rect_pos[1] - 16)), addText, (255, 255, 255), font=fontC)
image_x = np.array(img)
return image_x
if __name__ == '__main__':
filePath = "./FaceRecUI/test_img/朴信惠-1.jpeg"
img_rd = cv2.imdecode(np.fromfile(filePath, dtype=np.uint8), -1)
face_feature_exist = []
face_name_exist = []
flag = False
# 读取已存入的人脸特征信息
if os.path.exists("./features_all_test.csv"):
path_features_known_csv = "./features_all_test.csv"
csv_rd = pd.read_csv(path_features_known_csv, header=None, encoding='gb2312')
for i in range(csv_rd.shape[0]):
features_someone_arr = []
for j in range(1, 129):
if csv_rd.iloc[i][j] == '':
features_someone_arr.append('0')
else:
features_someone_arr.append(csv_rd.iloc[i][j])
face_feature_exist.append(features_someone_arr)
if csv_rd.iloc[i][0] == '':
face_name_exist.append("未知人脸")
else:
face_name_exist.append(csv_rd.iloc[i][0])
exist_flag = True
else:
exist_flag = False
# 使用人脸检测器进行人脸检测
image = img_rd.copy()
faces = detector(image, 0)
if len(faces) > 0:
# 矩形框 / Show the ROI of faces
face_feature_list = []
face_name_list = []
face_position_list = []
start_time = time.time()
for k, d in enumerate(faces):
# 计算矩形框大小 / Compute the size of rectangle box
height = (d.bottom() - d.top())
width = (d.right() - d.left())
hh = int(height / 2)
ww = int(width / 2)
y2 = d.right() + ww
x2 = d.bottom() + hh
y1 = d.left() - ww
x1 = d.top() - hh
# 判断人脸区域是否超出画面范围
if y2 > img_rd.shape[1]:
y2 = img_rd.shape[1]
elif x2 > img_rd.shape[0]:
x2 = img_rd.shape[0]
elif y1 < 0:
y1 = 0
elif x1 < 0:
x1 = 0
# 剪切出人脸
crop_face = img_rd[x1: x2, y1: y2]
# 获取人脸特征
shape = predictor(img_rd, d)
face_feature_list.append(face_reco_model.compute_face_descriptor(img_rd, shape))
current_face = crop_face
if exist_flag: # 获取已存在人脸的特征
for k in range(len(faces)):
# 初始化
face_name_list.append("未知人脸")
# 每个捕获人脸的名字坐标
face_position_list.append(tuple(
[faces[k].left(), int(faces[k].bottom() + (faces[k].bottom() - faces[k].top()) / 4)]))
# 对于某张人脸,遍历所有存储的人脸特征
current_distance_list = []
for i in range(len(face_feature_exist)):
# 如果 person_X 数据不为空
if str(face_feature_exist[i][0]) != '0.0':
e_distance_tmp = euclidean_distance(face_feature_list[k],
face_feature_exist[i])
current_distance_list.append(e_distance_tmp)
else:
# 空数据 person_X
current_distance_list.append(999999999)
# 寻找出最小的欧式距离匹配
min_dis = min(current_distance_list)
similar_person_num = current_distance_list.index(min_dis)
if min_dis < 0.4:
face_name_list[k] = face_name_exist[similar_person_num]
end_time = time.time()
fps_rec = int(1.0 / round((end_time - start_time), 3))
for k, d in enumerate(faces):
# 计算矩形框大小 / Compute the size of rectangle box
height = (d.bottom() - d.top())
width = (d.right() - d.left())
hh = int(height / 2)
ww = int(width / 2)
rect = (d.left(), d.top(), d.right(), d.bottom())
image = drawRectBox(image, rect, face_name_list[k])
cv2.imshow('Stream', image)
c = cv2.waitKey(0) & 0xff
源码获取:
🍅由于篇幅限制,获取完整文章或源码、代做项目的,拉到文章底部即可看到个人VX。🍅
大家点赞、收藏、关注、评论啦 、查看👇🏻获取联系方式👇🏻
更多推荐




所有评论(0)