黑松山资源网 Design By www.paidiu.com
1、代码
from aip import AipFace import cv2 import time import base64 from PIL import Image from io import BytesIO import pyttsx3 # """ 你的 APPID AK SK """ APP_ID = '1965####' API_KEY = 'YXL65ekIloykyjrT4kzc####' SECRET_KEY = 'lFiapBoZ5eBwOFyxMbiwQDmClg1u####' client = AipFace(APP_ID, API_KEY, SECRET_KEY) # def frame2base64(frame): # img = Image.fromarray(frame) #将每一帧转为Image # output_buffer = BytesIO() #创建一个BytesIO # img.save(output_buffer, format='JPEG') #写入output_buffer # byte_data = output_buffer.getvalue() #在内存中读取 # image = base64.b64encode(byte_data) #转为BASE64 # return image #转码成功 返回base64编码 def generate(): camera = cv2.VideoCapture(0) engine = pyttsx3.init() try: while True: engine = pyttsx3.init() ret, img = camera.read() cv2.imwrite("E://Ana/face.png",img) cv2.imshow("调用摄像头", img) imageType = "BASE64" groupIdList = "1,2,3,4" """ 如果有可选参数 """ options = {} options["max_face_num"] = 4 options["match_threshold"] = 70 options["quality_control"] = "NORMAL" options["liveness_control"] = "NONE" # options["user_id"] = "233451" options["max_user_num"] = 4 # """ 带参数调用人脸搜索 """ with open("E://Ana/face.png", 'rb') as fp: imageB = base64.b64encode(fp.read()) image = str(imageB, 'utf-8') """ 调用人脸搜索 """ result = client.search(image, imageType, groupIdList, options) engine.runAndWait() print(2) if result: if not result['result']: continue name = result['result']['user_list'][0]['user_id']#获取名字 score = result['result']['user_list'][0]['score']#获取相似度 if name == 'cgh_1': if score>80: print(score) print(name) engine.say("华来了") elif name == 'yjc_1': if score > 80: print(score) print(name) engine.say("杨来了") elif name == 'cjy_1': if score > 80: print(score) print(name) engine.say("言来了") elif name == 'hjy_1': if score > 80: print(score) print(name) engine.say("怡来了") else: print("匹配失败") else: continue except Exception as e: print(e) finally: # 释放资源 engine.runAndWait() camera.release() cv2.destroyAllWindows() generate()
2、实现步骤
2.1、获取百度ID和key
在百度API中可以申请到免费的API账号,每天有免费的几千次人脸识别,下图为我申请的API账号,然后在人脸库中创建需要识别的人脸就行了
2.2、创建客户端
APP_ID = '1965####' API_KEY = 'YXL65ekIloykyjrT4kzc####' SECRET_KEY = 'lFiapBoZ5eBwOFyxMbiwQDmClg1u####' client = AipFace(APP_ID, API_KEY, SECRET_KEY)
2.3、实现人脸识别
主要内容就是参数需要自己修改,然后获取视频图像,然后通过对比看一下,对比出来的名字,然后再看一下分数即可,我在里面加了一个电脑播报的,所以只要识别出来,电脑就会播报,延迟不超过以秒。
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年10月05日
2024年10月05日
- 群星《前途海量 电影原声专辑》[FLAC/分轨][227.78MB]
- 张信哲.1992-知道新曲与精丫巨石】【WAV+CUE】
- 王翠玲.1995-ANGEL【新艺宝】【WAV+CUE】
- 景冈山.1996-我的眼里只有你【大地唱片】【WAV+CUE】
- 群星《八戒 电影原声带》[320K/MP3][188.97MB]
- 群星《我的阿勒泰 影视原声带》[320K/MP3][139.47MB]
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[320K/MP3][148.91MB]
- 刘雅丽.2001-丽花皇后·EMI精选王【EMI百代】【FLAC分轨】
- 齐秦.1994-黄金十年1981-1990CHINA.TOUR.LIVE精丫上华】【WAV+CUE】
- 群星.2008-本色·百代音乐人创作专辑【EMI百代】【WAV+CUE】
- 群星.2001-同步过冬AVCD【环球】【WAV+CUE】
- 群星.2020-同步过冬2020冀待晴空【环球】【WAV+CUE】
- 沈雁.1986-四季(2012梦田复刻版)【白云唱片】【WAV+CUE】
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[FLAC/分轨][257.88MB]
- 《国语老歌 怀旧篇 3CD》[WAV/分轨][1.6GB]