Toggle navigation
Toggle navigation
This project
Loading...
Sign in
skywrace
/
drowsiness_detector
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
skywrace
2022-05-16 00:26:34 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9dfa1d636f3a5676066d5c1a4d7e8b8f13cdc164
9dfa1d63
1 parent
adb94818
chore: Adjust pin group to set right bound
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
DetectModel/main.py
DetectModel/main.py
View file @
9dfa1d6
...
...
@@ -44,6 +44,11 @@ def main():
pred
=
prob
.
argmax
(
axis
=-
1
)
return
True
if
pred
[
0
]
==
1
else
False
def
get_eye_open_dlib
(
frame
,
bound
):
l
,
r
=
min
(
map
(
lambda
x
:
x
[
0
],
bound
)),
max
(
map
(
lambda
x
:
x
[
0
],
bound
))
t
,
b
=
min
(
map
(
lambda
x
:
x
[
1
],
bound
)),
max
(
map
(
lambda
x
:
x
[
1
],
bound
))
cv2
.
rectangle
(
frame
,
(
l
,
t
),
(
r
,
b
),
(
0
,
255
,
0
),
2
)
while
True
:
frame
=
video
.
read
()
frame
=
imutils
.
resize
(
frame
,
width
=
640
)
...
...
@@ -64,13 +69,12 @@ def main():
shape
=
predictor
(
gray
,
rect
)
shape
=
face_utils
.
shape_to_np
(
shape
)
r_eye
=
shape
[
36
:
4
3
]
r_eye
=
shape
[
36
:
4
2
]
l_eye
=
shape
[
42
:
48
]
mouth
=
shape
[
48
:
69
]
for
(
x
,
y
)
in
l_eye
:
cv2
.
circle
(
frame
,
(
x
,
y
),
2
,
(
0
,
255
,
0
),
-
1
)
for
(
x
,
y
)
in
r_eye
:
cv2
.
circle
(
frame
,
(
x
,
y
),
2
,
(
0
,
255
,
0
),
-
1
)
mouth
=
shape
[
48
:]
get_eye_open_dlib
(
frame
,
r_eye
)
get_eye_open_dlib
(
frame
,
l_eye
)
for
(
x
,
y
)
in
mouth
:
cv2
.
circle
(
frame
,
(
x
,
y
),
2
,
(
0
,
255
,
0
),
-
1
)
...
...
Please
register
or
login
to post a comment