Skip to content

Commit

Permalink
Edit main, integrate spoofing detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
computervisioneng committed Dec 21, 2022
1 parent 3c8a443 commit 70c7241
Showing 1 changed file with 37 additions and 14 deletions.
51 changes: 37 additions & 14 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import face_recognition

import util
from test import test


class App:
Expand Down Expand Up @@ -57,27 +58,49 @@ def process_webcam(self):

def login(self):

name = util.recognize(self.most_recent_capture_arr, self.db_dir)
label = test(
image=self.most_recent_capture_arr,
model_dir='/home/phillip/Desktop/todays_tutorial/27_face_recognition_spoofing/code/face-attendance-system/Silent-Face-Anti-Spoofing/resources/anti_spoof_models',
device_id=0
)

if label == 1:

name = util.recognize(self.most_recent_capture_arr, self.db_dir)

if name in ['unknown_person', 'no_persons_found']:
util.msg_box('Ups...', 'Unknown user. Please register new user or try again.')
else:
util.msg_box('Welcome back !', 'Welcome, {}.'.format(name))
with open(self.log_path, 'a') as f:
f.write('{},{},in\n'.format(name, datetime.datetime.now()))
f.close()

if name in ['unknown_person', 'no_persons_found']:
util.msg_box('Ups...', 'Unknown user. Please register new user or try again.')
else:
util.msg_box('Welcome back !', 'Welcome, {}.'.format(name))
with open(self.log_path, 'a') as f:
f.write('{},{},in\n'.format(name, datetime.datetime.now()))
f.close()
util.msg_box('Hey, you are a spoofer!', 'You are fake !')

def logout(self):

name = util.recognize(self.most_recent_capture_arr, self.db_dir)
label = test(
image=self.most_recent_capture_arr,
model_dir='/home/phillip/Desktop/todays_tutorial/27_face_recognition_spoofing/code/face-attendance-system/Silent-Face-Anti-Spoofing/resources/anti_spoof_models',
device_id=0
)

if label == 1:

name = util.recognize(self.most_recent_capture_arr, self.db_dir)

if name in ['unknown_person', 'no_persons_found']:
util.msg_box('Ups...', 'Unknown user. Please register new user or try again.')
else:
util.msg_box('Hasta la vista !', 'Goodbye, {}.'.format(name))
with open(self.log_path, 'a') as f:
f.write('{},{},out\n'.format(name, datetime.datetime.now()))
f.close()

if name in ['unknown_person', 'no_persons_found']:
util.msg_box('Ups...', 'Unknown user. Please register new user or try again.')
else:
util.msg_box('Welcome back !', 'Welcome, {}.'.format(name))
with open(self.log_path, 'a') as f:
f.write('{},{},out\n'.format(name, datetime.datetime.now()))
f.close()
util.msg_box('Hey, you are a spoofer!', 'You are fake !')


def register_new_user(self):
Expand Down

1 comment on commit 70c7241

@yuan8989
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have error in the line "from test import test"
and there are many test pakage to download, I tried some but the error did not go away

Please sign in to comment.