commit 240ac8b6694dee5de912c8d637a8544cee829330 Author: dorodnic Date: Sun May 28 21:00:11 2023 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9b4575 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +pictures/* diff --git a/authenticate.py b/authenticate.py new file mode 100644 index 0000000..737ac65 --- /dev/null +++ b/authenticate.py @@ -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() diff --git a/enroll.py b/enroll.py new file mode 100644 index 0000000..29956aa --- /dev/null +++ b/enroll.py @@ -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) + + diff --git a/list_users.py b/list_users.py new file mode 100644 index 0000000..a1245ff --- /dev/null +++ b/list_users.py @@ -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) + + diff --git a/rsid-cli b/rsid-cli new file mode 100755 index 0000000..cbb77cc Binary files /dev/null and b/rsid-cli differ diff --git a/rsid_py.cpython-37m-arm-linux-gnueabihf.so b/rsid_py.cpython-37m-arm-linux-gnueabihf.so new file mode 100755 index 0000000..a0547cb Binary files /dev/null and b/rsid_py.cpython-37m-arm-linux-gnueabihf.so differ