Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
klorydryk
FacialRecoTrackingScore
Commits
c0aa4f99
Commit
c0aa4f99
authored
Jan 23, 2020
by
cb
Browse files
Code cleaning: Added some Global Variables
parent
f321244b
Changes
1
Hide whitespace changes
Inline
Side-by-side
trackmultiplefaces.py
View file @
c0aa4f99
...
...
@@ -24,14 +24,27 @@ faceCascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
OUTPUT_SIZE_WIDTH
=
775
OUTPUT_SIZE_HEIGHT
=
600
RED
=
(
0
,
0
,
255
)
BLUE
=
(
255
,
0
,
0
)
# Colors
WHITE
=
(
255
,
255
,
255
)
RED
=
(
0
,
0
,
255
)
BLUE
=
(
255
,
0
,
0
)
PURPLE
=
(
127
,
0
,
255
)
GREEN
=
(
0
,
255
,
0
)
GREEN
=
(
0
,
255
,
0
)
suspiciousColors
=
{
0
:(
0
,
0
,
0
),
1
:
GREEN
,
2
:
PURPLE
,
3
:
RED
}
averageSuspicious
=
0
NAME_COLOR
=
WHITE
IDENTIFYING_COLOR
=
WHITE
# The default color of the rectangle we draw around the face
rectangleColor
=
(
0
,
165
,
255
)
rectangleColorSuspicious
=
RED
# Suspicious threshold
SUSPICIOUS_THRESHOLD
=
2
#We are not doing really face recognition
def
doRecognizePerson
(
faceNames
,
fid
):
time
.
sleep
(
2
)
...
...
@@ -66,9 +79,6 @@ def detectAndTrackMultipleFaces(start_thread,
#Start the window thread for the two windows we are using
cv2
.
startWindowThread
()
#The color of the rectangle we draw around the face
rectangleColor
=
(
0
,
165
,
255
)
#variables holding the current frame number and the current faceid
frameCounter
=
0
currentFaceID
=
0
...
...
@@ -287,7 +297,7 @@ def detectAndTrackMultipleFaces(start_thread,
(
t_x
+
int
((
t_w
-
len
(
faceNames
[
fid
])
*
10
)
/
2
+
10
),
int
(
t_y
)
-
10
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
(
255
,
255
,
255
)
,
NAME_COLOR
,
1
,
cv2
.
LINE_AA
)
...
...
@@ -296,8 +306,7 @@ def detectAndTrackMultipleFaces(start_thread,
put_warning_message
(
fid
,
faceTrackers
,
faceSuspicion
,
resultImage
,
threshold
=
2
)
resultImage
)
# Else print Identifying
else
:
...
...
@@ -307,7 +316,7 @@ def detectAndTrackMultipleFaces(start_thread,
(
t_x
+
int
((
t_w
-
len
(
text
)
*
10
)
/
2
+
10
),
int
(
t_y
)),
cv2
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
(
255
,
255
,
255
)
,
IDENTIFYING_COLOR
,
1
,
cv2
.
LINE_AA
)
...
...
@@ -334,7 +343,7 @@ def detectAndTrackMultipleFaces(start_thread,
cv2
.
destroyAllWindows
()
exit
(
0
)
def
put_warning_message
(
fid
,
faceTrackers
,
faceSuspicion
,
resultImage
,
threshold
=
2
):
def
put_warning_message
(
fid
,
faceTrackers
,
faceSuspicion
,
resultImage
):
'''
Print a Warning message depending on suspicion level
'''
...
...
@@ -347,8 +356,8 @@ def put_warning_message(fid, faceTrackers, faceSuspicion, resultImage, threshold
suspicion_level
=
faceSuspicion
[
fid
]
if
suspicion_level
>
threshold
:
text
=
"ATTENTION!
INDIVIDU
DANGEREU
X
!"
if
suspicion_level
>
SUSPICIOUS_THRESHOLD
:
text
=
"ATTENTION!
PERSONNE
DANGEREU
SE
!"
cv2
.
putText
(
resultImage
,
text
,
# Name's alignment
...
...
@@ -388,15 +397,15 @@ def rectangle_around_face(fid, faceTrackers, faceSuspicion, draw_person_dangeros
person_color
,
1
)
def
pick_person_dangerosity_color
(
suspicionLevel
,
threshold
=
2
):
def
pick_person_dangerosity_color
(
suspicionLevel
):
'''
Compute person level suspicion -> simplified to 2 levels
Can reintroduce the faceSuspicious dictionnary lated, was more clean
'''
if
suspicionLevel
>
threshold
:
color
=
RED
if
suspicionLevel
>
SUSPICIOUS_THRESHOLD
:
color
=
rectangleColorSuspicious
else
:
color
=
GREEN
color
=
rectangleColor
return
color
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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