initial commit
This commit is contained in:
commit
240ac8b669
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
pictures/*
|
46
authenticate.py
Normal file
46
authenticate.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
"""
|
||||||
|
License: Apache 2.0. See LICENSE file in root directory.
|
||||||
|
Copyright(c) 2020-2021 Intel Corporation. All Rights Reserved.
|
||||||
|
"""
|
||||||
|
import requests
|
||||||
|
import subprocess
|
||||||
|
import rsid_py
|
||||||
|
import os
|
||||||
|
from gpiozero import Button, LED
|
||||||
|
from time import sleep
|
||||||
|
from signal import pause
|
||||||
|
|
||||||
|
button = Button("15")
|
||||||
|
ledRed = LED("14")
|
||||||
|
ledGreen = LED("18")
|
||||||
|
|
||||||
|
PORT='/dev/ttyACM0'
|
||||||
|
|
||||||
|
def on_result(result, user_id):
|
||||||
|
print('on_result', result)
|
||||||
|
if result == rsid_py.AuthenticateStatus.Success:
|
||||||
|
takePhoto("success")
|
||||||
|
sleep(1.5)
|
||||||
|
ledGreen.on()
|
||||||
|
sleep(2)
|
||||||
|
ledGreen.off()
|
||||||
|
else:
|
||||||
|
takePhoto("failure")
|
||||||
|
sleep(1.5)
|
||||||
|
ledRed.on()
|
||||||
|
sleep(2)
|
||||||
|
ledRed.off()
|
||||||
|
|
||||||
|
def authentication():
|
||||||
|
with rsid_py.FaceAuthenticator(PORT) as f:
|
||||||
|
f.authenticate(on_result=on_result)
|
||||||
|
|
||||||
|
def takePhoto(result):
|
||||||
|
filename = subprocess.check_output("date +%Y-%m-%d_%H-%M-%S", shell=True).decode().strip() + "-" + result + ".jpg"
|
||||||
|
subprocess.run(["ffmpeg", "-f", "video4linux2", "-i", "/dev/video0", "-vframes", "1", filename])
|
||||||
|
os.rename(filename, os.path.join("pictures", filename))
|
||||||
|
subprocess.run(["rsync", "-avz", "-e", "ssh", "pictures/", "valer@10.8.0.1:/var/www/valerjakubco.xyz/storage/app/public/pictures/"])
|
||||||
|
|
||||||
|
|
||||||
|
button.when_pressed = authentication
|
||||||
|
pause()
|
39
enroll.py
Normal file
39
enroll.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
"""
|
||||||
|
License: Apache 2.0. See LICENSE file in root directory.
|
||||||
|
Copyright(c) 2020-2021 Intel Corporation. All Rights Reserved.
|
||||||
|
"""
|
||||||
|
import rsid_py
|
||||||
|
import sys
|
||||||
|
import logging
|
||||||
|
|
||||||
|
PORT="/dev/ttyACM0"
|
||||||
|
|
||||||
|
def on_result(result):
|
||||||
|
print('on_result', result)
|
||||||
|
|
||||||
|
def on_progress(p):
|
||||||
|
print(f'on_progress {p}')
|
||||||
|
|
||||||
|
def on_hint(h):
|
||||||
|
print(f'on_hint {h}')
|
||||||
|
|
||||||
|
def on_faces(faces, timestamp):
|
||||||
|
print(f'detected {len(faces)} face(s)')
|
||||||
|
for f in faces:
|
||||||
|
print(f'\tface {f.x},{f.y} {f.w}x{f.h}')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
with rsid_py.FaceAuthenticator(PORT) as f:
|
||||||
|
# user_id = input()
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
user_id = sys.argv[1]
|
||||||
|
f.enroll(user_id=user_id, on_hint=on_hint, on_progress=on_progress, on_faces=on_faces, on_result=on_result)
|
||||||
|
else:
|
||||||
|
print('Chyba')
|
||||||
|
exit()
|
||||||
|
#display list of enrolled users
|
||||||
|
users = f.query_user_ids()
|
||||||
|
print('Users: ', users)
|
||||||
|
|
||||||
|
|
15
list_users.py
Normal file
15
list_users.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
"""
|
||||||
|
License: Apache 2.0. See LICENSE file in root directory.
|
||||||
|
Copyright(c) 2020-2021 Intel Corporation. All Rights Reserved.
|
||||||
|
"""
|
||||||
|
import rsid_py
|
||||||
|
|
||||||
|
PORT='/dev/ttyACM0'
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
with rsid_py.FaceAuthenticator(PORT) as f:
|
||||||
|
#display list of enrolled users
|
||||||
|
users = f.query_user_ids()
|
||||||
|
print('Users: ', users)
|
||||||
|
|
||||||
|
|
BIN
rsid_py.cpython-37m-arm-linux-gnueabihf.so
Executable file
BIN
rsid_py.cpython-37m-arm-linux-gnueabihf.so
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user