python - 检测到人时显示图像
问题描述
我有一个实时面部识别程序,可以识别我认识的人的面孔,然后在上面写下这个人的名字。现在,当检测到诸如“亚历克斯”之类的人时,我将显示我为这个人看到的图像并在几秒钟后将其关闭,然后再关闭新人这是我的一段代码:
for face_encoding in face_encodings:
# match = face_recognition.compare_faces(known_face_encoding, face_encoding)
# Matches=np.where(match)[0] #Checking which image is matched
face_distances=face_recognition.face_distance(face_encodings, face_encoding)
Matches =list(face_distances<= 0.4)
name="Unknown"
if True in Matches:
match_index = np.argmin(face_distances)
name = known_person[match_index]
face_names.append(name)
正如你所看到的,这个名字代表了人们的名字我是怎么做的?请帮助我提前谢谢你
解决方案
您的问题尚不清楚,但是无论如何,一旦您正确识别了此人的姓名并且想要将他/她的图像显示到屏幕上,只需使用 OpenCV 库中的 imshow 函数即可。
这里的代码片段可能会帮助您到达那里:
import cv2
#YOUR CODE LOGIC ... --> you get the name of the person that has been detected
if (name == "Alex"):
picture = cv2.imread("Alex.jpg")
cv2.imshow(name, picture)
cv2.waitKey()
cv2.destroyAllWindows()
推荐阅读
- java - 使用 java ftp 检查 mainfame 上是否存在数据集
- php - 生产中的 PHP 无法识别来自 Angular 6 帖子的 $_REQUEST
- graphite - 如何以没有 root 权限的用户身份安装石墨及其所有先决条件?
- android - 数组作为改造中的参数
- module - 如何在每个新项目中使用 Pycharm IDE 中安装的 Python 项目包
- xamarin.forms - 如何检测语音是否在 Xamarin Forms 上
- excel - 使用 Google Drive 导入范围 Exel 公式
- python - 在 Altair 中设置 count() 截止值?
- docker - Docker 构建失败,没有名为 pip._vendor 的模块用于气流 1.10.0 和 python 2.7
- spring - Spring Security 中的多个入口点