2 Star 0 Fork 0

kingking / 百度人脸识别人脸注册软件

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

百度人脸识别人脸注册软件

软件界面 (Userid不能包含中文):

软件界面

文件信息

     |——ico
     |  |——baidu.ico
     |——LoginInfo.txt  #用户登录百度云的App ID、Api Key、Secret Key数据,需要自己注册百度云账号
     |——updata.py  #主程序,python3.6

安装百度人脸识别库

在这注册并下载查阅相关信息 百度云网址

在Linux设备上安装需要管理员权限,比如树莓派

如果已安装pip,执行pip install baidu-aip即可。
如果已安装setuptools,在百度云下载安装包,执行python setup.py install即可。

LoginInfo.txt详细介绍

from aip import AipFace
""" 你的 APPID AK SK """
APP_ID = '你的 App ID'
API_KEY = '你的 Api Key'
SECRET_KEY = '你的 Secret Key'
client = AipFace(APP_ID, API_KEY, SECRET_KEY)

如上代码片所示,注册新用户时获得一个接口需要三个参数,这三个参数以JSON格式写在LoginInfo.txt中

"""在LoginInfo.txt中写入自己的三个登录信息"""
{"appid":"94****2", "apikey":"Dal1gu0F8*******kaClU4EW", "secretkey":"VNHzN*******yn0Qxjs"}

updata.py详细介绍

from tkinter import *
import tkinter
import tkinter.filedialog
import tkinter.messagebox
from aip import AipFace
import json
"""选择要提交的图片并返回图片的二进制信息"""
def select_image():
    global image
    path = tkinter.filedialog.askopenfilename()
    path_label = Label(text=path)
    path_label.grid(row=0,column=1)
    with open(path, 'rb') as fp:
        image=[]
        image.append(fp.read())
"""获取用户输入创建百度云接口实例并提交信息"""    
def updatauser():
    global image  #全局化image
    if image != []:  #只有image里面有内容,即用户选择了图片才会执行
        with open('LoginInfo.txt', 'r') as fp:  #打开LoginInfo.txt
            info = json.loads(fp.read())  #登录信息转换成JSON数据
        client = AipFace(info['appid'], info['apikey'], info['secretkey'])  #根据登录信息创建百度云实例
        options = {}
        options["action_type"] = "replace"  #注册新用户的额外选项,replace的意思估计是更新,我没查
        return_info = client.addUser(userid_entry.get(), userinfo_entry.get(),\
                                     groupid_entry.get(), image[0], options)  #注册/更新新用户
        if 'error_code' in return_info.keys():  #判断返回数据是否包含更新失败关键字
            tkinter.messagebox.showerror('参数输入错误', '注意:Userid不能包含中文字符!')
        else:  #更新成功
            tkinter.messagebox.showinfo('成功', '新用户信息提交成功!')
    else:  #image里面没有有内容
        tkinter.messagebox.showerror('选择文件错误', '请重新选择图片')
    
image = []
#以下为tkinter内容,在这不做介绍
root = Tk()
root.title('百度人脸注册工具')
try:
    root.iconbitmap('ico/baidu.ico')#linux平台没有这个方法
except:
    pass
button = Button(text='选择图片',command = select_image)
button.grid(row=0,column=0,padx=2,pady=2)
userid_label = Label(text='Userid:')
userid_label.grid(row=1,column=0,padx=2,pady=2)
userid_entry = Entry(width=40)
userid_entry.grid(row=1,column=1,padx=2,pady=2)
userinfo_label = Label(text='Userinfo:')
userinfo_label.grid(row=2,column=0,padx=2,pady=2)
userinfo_entry = Entry(width=40)
userinfo_entry.grid(row=2,column=1,padx=2,pady=2)
groupid_label = Label(text='Groupid :')
groupid_label.grid(row=3,column=0,padx=2,pady=2)
e = StringVar()  #Entry默认输入编程方式
groupid_entry = Entry(textvariable=e, width=40)
groupid_entry.grid(row=3,column=1,padx=2,pady=2)
e.set('group1')  #Entry默认输入编程方式
updata = Button(text='提交用户',command = updatauser)
updata.grid(row=7,column=1,sticky=tkinter.E,padx=2,pady=2)
root.mainloop()

空文件

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangkingking/BaiDuRenLianShiBieRenLianZhuCe.git
git@gitee.com:wangkingking/BaiDuRenLianShiBieRenLianZhuCe.git
wangkingking
BaiDuRenLianShiBieRenLianZhuCe
百度人脸识别人脸注册软件
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891