[英]Adding Face Recognition functionality to a face detection program
我有一个人脸检测程序,可以在看到人脸时在其周围绘制一个矩形。 但是,我希望我的程序能够识别某些面孔并能够显示面孔的名称。
这是我当前的代码:
import cv2
#load the cascade
face_cascade =
cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
#capture video from webcam
cap = cv2.VideoCapture(0)
#continuously capture video
while True:
#read the frame
_, img = cap.read()
#convert to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#detect a face
faces = face_cascade.detectMultiScale(gray, 1.1, 4)
#draw a rectangle to confirm face
for (x, y, w, h) in faces:
cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
#display video
cv2.imshow('img', img)
#stop if escape key is pressed
k = cv2.waitKey(30) & 0xff
if k == 27:
break
#release the video capture object
cap.release()
如何在仍然使用我拥有的代码而又不进行任何重大更改的情况下实现人脸识别? 任何帮助将不胜感激。
没关系,我知道了。 我决定在此页面的帮助下使用face_recognition
库: 在此处输入链接描述
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.