Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
F
face-recognition
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
se101-team-flex
face-recognition
Commits
a5745728
Commit
a5745728
authored
Oct 27, 2019
by
Kyle Anderson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small refactorings
Just did some small refactorings on some of the files.
parent
92ff71a8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
11 deletions
+12
-11
authenticate_user.py
authenticate_user.py
+9
-8
create_known_encoding.py
create_known_encoding.py
+3
-0
create_recognition_profile.py
create_recognition_profile.py
+0
-3
No files found.
authenticate_user.py
View file @
a5745728
...
...
@@ -38,21 +38,20 @@ def determine_identity(face_encoding, known_faces):
"""Determines the most likely identity of a single face. Returns the user id."""
matches
=
face_recognition
.
compare_faces
(
known_faces
[
"encodings"
],
face_encoding
)
matched_user
=
None
matched_user
=
''
matched_user_id_count
=
{}
# If there is at least one match to a face in the database, figure out which one it is.
if
True
in
matches
:
matched_user_id_count
=
{}
matched_users
=
[
user_index
for
(
user_index
,
is_match
)
in
enumerate
(
matches
)
if
is_match
]
for
i
in
matched_users
:
user_id
:
str
=
known_faces
[
"user_ids"
][
i
]
matched_user_id_count
[
user_id
]
=
matched_user_id_count
.
get
(
user_id
,
0
)
+
1
matched_user_id_count
[
user_id
]
=
matched_user_id_count
.
get
(
user_id
,
0
)
+
1
matched_user
:
str
=
max
(
matched_user_id_count
,
key
s
=
matched_user_id_count
.
get
()
)
key
=
matched_user_id_count
.
get
)
return
matched_user
...
...
@@ -65,6 +64,7 @@ def check_recognized_users(recognized_user_counts):
recognized_users
.
append
(
user_id
)
return
recognized_users
def
draw_rectanges_and_user_ids
(
image_frame
,
conversion
:
float
,
boxes
,
user_ids
:
list
):
"""Draws the rectangles and user_ids onto the video stream so anyone viewing the stream could see them."""
for
((
top
,
right
,
bottom
,
left
),
user_id
)
in
zip
(
boxes
,
user_ids
):
...
...
@@ -80,6 +80,7 @@ def draw_rectanges_and_user_ids(image_frame, conversion: float, boxes, user_ids:
cv2
.
putText
(
image_frame
,
user_id
,
(
left
,
y
),
cv2
.
FONT_HERSHEY_PLAIN
,
0.75
,
(
0
,
255
,
0
),
2
)
display_frame
(
image_frame
)
def
display_frame
(
frame
):
"""Displays the frame to the user."""
cv2
.
imshow
(
"Frame"
,
frame
)
...
...
@@ -98,8 +99,8 @@ def recognize_user():
# Determine the time at which we will time out. Equal to current time + timeout.
timeout_time
:
float
=
time
.
time
()
+
TIMEOUT
while
(
time
.
time
()
<
timeout_time
and
not
user_recognized
)
:
# Read a image_frame from the videostream.
while
time
.
time
()
<
timeout_time
and
not
user_recognized
:
# Read a image_frame from the video
stream.
image_frame
=
video_stream
.
read
()
# Convert input from BGR to RGB
...
...
@@ -130,7 +131,7 @@ def recognize_user():
break
recognized_user
=
max
(
recognized_users_count
,
key
s
=
recognized_users_count
.
get
()
)
key
=
recognized_users_count
.
get
)
if
recognized_users_count
[
recognized_user
]
<
MIN_USER_RECOGNITION_COUNT
:
recognized_user
=
None
return
recognized_user
...
...
create_known_encoding.py
0 → 100644
View file @
a5745728
"""
Creates a facial recognition profile for a new user.
"""
create_recognition_profile.py
deleted
100644 → 0
View file @
92ff71a8
"""
Creates a facial recongnition profile for a new user.
"""
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment