用户:
善良的导弹鲨581查看:3 回复:10 评论:3 创建时间:2020-01-25T16:53:46
【作品展示】

【作品介绍】
搞笑的人脸识别效果自己试试看吧
【作品源代码】
import easygui
import codemao
import time
import turtle
while (0 == 0):
easygui.msgbox('界面出来后按下空格照相,图片打开后有10秒钟的观看时间,结果会是你的......')
image = codemao.take_photos("space_pressed")
image.face_comment(("age", "gender", "emotion")).open_image()
time.sleep(10)
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn
QBZ_import cv2
# 人脸检测器
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades+'haarcascade_frontalface_default.xml')
# 打开摄像头
vc=cv2.VideoCapture(0)
# 设置视频画面的宽度为480像素,高度为320像素
vc.set(cv2.CAP_PROP_FRAME_WIDTH,480)
vc.set(cv2.CAP_PROP_FRAME_HEIGHT, 320)
while True:
retval,frame=vc.read()
if not retval or cv2.waitKey(16) & 0xFF == ord("1"):
break
gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray,1.3,5)
font = cv2.FONT_HERSHEY_SIMPLEX
for (x, y, w, h) in faces:
cv2.putText(frame, "face", (x-20, y-10),
font, 0.55, (255, 0, 0), 1)
cv2.rectangle(frame, (x, y), (x+w, y+h), (255, 0, 0), 3)
cv2.imshow('Video', frame)
# 关闭摄像头
vc.release()
cv2.destroyAllWindows()
点赞1
评论