# coding:<encoding name> : # coding: utf-8
from aip import AipFace
from picamera import PiCamera
import urllib.request
import RPi.GPIO as GPIO
import base64
import time
import serial
ser = serial.Serial('dev/ttyACM0', 9600,timeout=1)
APP_ID = '22797401'
API_KEY = 'jed1mol8bzVFDFlleNGIchY1'
SECRET_KEY ='q8A27p3Q2DDshgWG1m3RGzUfNVxvvtQ0'
client = AipFace(APP_ID, API_KEY, SECRET_KEY)
IMAGE_TYPE='BASE64'
camera = PiCamera()
GROUP = 'zxy_01'
def servo_init():
ser.write("1")
def bt_open():
ser.write("2")
def bt_close():
ser.write("3")
def getimage():
camera.resolution = (1024,768)
camera.start_preview()
time.sleep(2)
camera.capture('faceimage.jpg')
time.sleep(2)
def transimage():
f = open('faceimage.jpg','rb')
img = base64.b64encode(f.read())
return img
def go_api(image):
result = client.search(str(image, 'utf-8'), IMAGE_TYPE, GROUP);
if result['error_msg'] == 'SUCCESS':
name = result['result']['user_list'][0]['user_id']
score = result['result']['user_list'][0]['score']
if score > 80:
if name == 'zxy_01':
print("欢迎%s !" % name)
time.sleep(3)
if name == 'xiaoming':
print("welcome%s !" % name)
time.sleep(3)
if name == "xiaoyu":
print("welcome%s !" % name)
else:
print("你是陌生人,不欢迎!!")
name = 'Unknow'
return 0
return 1
if result['error_msg'] == 'pic not has face':
print('未能检测到人脸,请移动位置')
time.sleep(2)
return -1
else:
print(result['error_code']+' ' + result['error_code'])
return 0
if __name__ == '__main__':
while True:
print('开始了,请准备')
if True:
getimage()
img = transimage()
res = go_api(img)
if(res == 1):
bt_open()
print("门已为尊贵的你打开")
elif(res == -1):
print("看不见你我要关门了")
time.sleep(3)
bt_close()
else:
print('关门了')
bt_close()
time.sleep(3)
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
人脸识别门禁系统.zip (3个子文件)
人脸识别门禁系统
人脸识别门禁系统作品展示.mp4 17.54MB
test.py 2KB
bluetooth_test.py 274B
共 3 条
- 1
zstar-_
- 粉丝: 12w+
- 资源: 74
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0