Python人脸识别源代码可自动识别出年龄、性别等

阅读: 评论:0

小型地源热泵Python⼈脸识别源代码可⾃动识别出年龄性别等利⽤百度AI进⾏⼈脸识别,可⾃动识别出年龄、性别等信息,准确率⾮常⾼。运⾏程序前请安装需要的模块
饮用水过滤器import base64
from aip import AipFace
import cv2
# 配置百度aip参数
APP_ID ='19484855'
API_KEY ='V2mDOleCsk3yEE6P5MgVwSjI'
SECRET_KEY ='RbRMAuPmz8QpDweikrbpfGQjXUm7HiCD'
a_face = AipFace(APP_ID, API_KEY, SECRET_KEY)
image_type ='BASE64'
options ={'face_field':'age,gender,beauty',"max_face_num":10}
max_face_num =10
def get_file_content(file_path):
"""获取⽂件内容"""
with open(file_path,'rb')as fr:
content = base64.ad())
return content.decode('utf8')
def face_score(file_path):
polar code"""脸部识别分数"""
result = a_face.detect(get_file_content(file_path), image_type, options) return result
# 图⽚地址,图⽚与程序同⼀⽬录下
file_path ="timg.jpg"
result = face_score(file_path)
# #从⽂件读取图像并转为灰度图像
脉冲信号
img = cv2.imread(file_path)
# 图⽚放⽂字
# 设置⽂件的位置、字体、颜⾊等参数
font = cv2.FONT_HERSHEY_DUPLEX
# font = uetype("f", 20, encoding="utf-8")
color =(0,0,255)
磁分离for item in result['result']['face_list']:
x =int(item['location']['left'])
y =int(item['location']['top'])
w = item['location']['width']
h = item['location']['height']
age = item['age']
beauty = item['beauty']
gender = item['gender']['type']
cv2.putText(img,'age:%s'% age,(x, y + h +10), font,1, color,1)
cv2.putText(img,'beauty:%s'% beauty,(x, y + h +30), font,1, color,1)    cv2.putText(img,'gender:%s'% gender,(x, y + h +50), font,1, color,1)
cv2.imshow('Image', img)
# 按任意键退出
key = cv2.waitKey()
if key ==27:
# 销毁所有窗⼝
cv2.destroyAllWindows()
更多Python源代码,请关注:Python代码⼤全,
>射频调制器

本文发布于:2023-06-04 23:48:53,感谢您对本站的认可!

本文链接:https://patent.en369.cn/patent/4/126428.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:识别   性别   位置   图像   年龄   源代码   需要
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 369专利查询检索平台 豫ICP备2021025688号-20 网站地图