Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.pad.face
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.pad.face
Commits
ee46bf68
There was a problem fetching the pipeline summary.
Commit
ee46bf68
authored
7 years ago
by
Olegs NIKISINS
Browse files
Options
Downloads
Patches
Plain Diff
Changed function name + some minor modifications
parent
8323a99f
No related branches found
No related tags found
1 merge request
!24
Facedet utils generic
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/pad/face/utils/face_detection_utils.py
+18
-32
18 additions, 32 deletions
bob/pad/face/utils/face_detection_utils.py
with
18 additions
and
32 deletions
bob/pad/face/utils/face_detection_utils.py
+
18
−
32
View file @
ee46bf68
...
@@ -11,24 +11,23 @@ import importlib
...
@@ -11,24 +11,23 @@ import importlib
import
numpy
as
np
import
numpy
as
np
#==============================================================================
def
get
EyeP
os
(
lm
):
def
get
_eye_p
os
(
lm
):
"""
"""
This function returns the locations of left and right eyes
This function returns the locations of left and right eyes
**Parameters:**
**Parameters:**
``lm`` : :py:class:`array`
``lm`` : :py:class:`array`
A numpy array containing the coordinates of facial landmarks, (68X2)
A numpy array containing the coordinates of facial landmarks, (68X2)
**Returns:**
**Returns:**
``right_eye``
``right_eye``
A tuple containing the location of right eye,
A tuple containing the location of right eye,
``left_eye``
``left_eye``
A tuple containing the location of left eye
A tuple containing the location of left eye
"""
"""
...
@@ -38,14 +37,10 @@ def getEyePos(lm):
...
@@ -38,14 +37,10 @@ def getEyePos(lm):
left_eye_t
=
(
lm
[
36
,:]
+
lm
[
39
,:])
/
2.0
left_eye_t
=
(
lm
[
36
,:]
+
lm
[
39
,:])
/
2.0
right_eye_t
=
(
lm
[
42
,:]
+
lm
[
45
,:])
/
2.0
right_eye_t
=
(
lm
[
42
,:]
+
lm
[
45
,:])
/
2.0
right_eye
=
(
int
(
left_eye_t
[
1
]),
int
(
left_eye_t
[
0
]))
right_eye
=
(
int
(
left_eye_t
[
1
]),
int
(
left_eye_t
[
0
]))
left_eye
=
(
int
(
right_eye_t
[
1
]),
int
(
right_eye_t
[
0
]))
left_eye
=
(
int
(
right_eye_t
[
1
]),
int
(
right_eye_t
[
0
]))
return
right_eye
,
left_eye
return
right_eye
,
left_eye
#==============================================================================
#==============================================================================
...
@@ -134,10 +129,9 @@ def detect_faces_in_video(frame_container, method = "dlib"):
...
@@ -134,10 +129,9 @@ def detect_faces_in_video(frame_container, method = "dlib"):
annotations
[
str
(
idx
)]
=
frame_annotations
annotations
[
str
(
idx
)]
=
frame_annotations
return
annotations
return
annotations
#==============================================================================
def
detect_face_landmarks_in_image
(
image
,
method
=
"
dlib
"
):
def
detect_face_landmarks_in_image
(
image
,
method
=
"
dlib
"
):
"""
"""
This function detects a face in the input image. Two oprions for face detector , but landmark detector is always the same
This function detects a face in the input image. Two oprions for face detector , but landmark detector is always the same
...
@@ -169,19 +163,17 @@ def detect_face_landmarks_in_image(image, method = "dlib"):
...
@@ -169,19 +163,17 @@ def detect_face_landmarks_in_image(image, method = "dlib"):
except
ImportError
:
except
ImportError
:
print
(
"
No module named bob.ip.
"
+
method
+
"
trying to use default method!
"
)
print
(
"
No module named bob.ip.
"
+
method
+
"
trying to use default method!
"
)
try
:
try
:
face_detection_module
=
importlib
.
import_module
(
"
bob.ip.dlib
"
)
face_detection_module
=
importlib
.
import_module
(
"
bob.ip.dlib
"
)
method
=
"
dlib
"
method
=
"
dlib
"
except
ImportError
:
except
ImportError
:
raise
ImportError
(
"
No module named bob.ip.dlib
"
)
raise
ImportError
(
"
No module named bob.ip.dlib
"
)
if
not
hasattr
(
face_detection_module
,
'
FaceDetector
'
):
if
not
hasattr
(
face_detection_module
,
'
FaceDetector
'
):
raise
AttributeError
(
"
bob.ip.
"
+
method
+
"
module has no attribute FaceDetector!
"
)
raise
AttributeError
(
"
bob.ip.
"
+
method
+
"
module has no attribute FaceDetector!
"
)
#### Landmark detector
#### Landmark detector
try
:
try
:
...
@@ -191,14 +183,11 @@ def detect_face_landmarks_in_image(image, method = "dlib"):
...
@@ -191,14 +183,11 @@ def detect_face_landmarks_in_image(image, method = "dlib"):
if
not
hasattr
(
landmark_detection_module
,
'
detect_landmarks_on_boundingbox
'
):
if
not
hasattr
(
landmark_detection_module
,
'
detect_landmarks_on_boundingbox
'
):
raise
AttributeError
(
"
bob.ip.facelandmarksmodule has no attribute detect_landmarks_on_boundingbox!
"
)
raise
AttributeError
(
"
bob.ip.facelandmarksmodule has no attribute detect_landmarks_on_boundingbox!
"
)
face_detector
=
face_detection_module
.
FaceDetector
()
face_detector
=
face_detection_module
.
FaceDetector
()
data
=
face_detector
.
detect_single_face
(
image
)
data
=
face_detector
.
detect_single_face
(
image
)
annotations
=
{}
annotations
=
{}
if
(
data
is
not
None
)
and
(
not
all
([
x
is
None
for
x
in
data
])
):
if
(
data
is
not
None
)
and
(
not
all
([
x
is
None
for
x
in
data
])
):
...
@@ -217,8 +206,7 @@ def detect_face_landmarks_in_image(image, method = "dlib"):
...
@@ -217,8 +206,7 @@ def detect_face_landmarks_in_image(image, method = "dlib"):
#print("LM",lm)
#print("LM",lm)
right_eye
,
left_eye
=
getEyePos
(
lm
)
right_eye
,
left_eye
=
get_eye_pos
(
lm
)
points
=
[]
points
=
[]
...
@@ -236,13 +224,10 @@ def detect_face_landmarks_in_image(image, method = "dlib"):
...
@@ -236,13 +224,10 @@ def detect_face_landmarks_in_image(image, method = "dlib"):
annotations
[
'
right_eye
'
]
=
right_eye
annotations
[
'
right_eye
'
]
=
right_eye
return
annotations
return
annotations
#==============================================================================
def
detect_face_landmarks_in_video
(
frame_container
,
method
=
"
dlib
"
):
def
detect_face_landmarks_in_video
(
frame_container
,
method
=
"
dlib
"
):
"""
"""
This function detects a face and face landmarks in each farme of the input video.
This function detects a face and face landmarks in each farme of the input video.
...
@@ -288,3 +273,4 @@ def detect_face_landmarks_in_video(frame_container, method = "dlib"):
...
@@ -288,3 +273,4 @@ def detect_face_landmarks_in_video(frame_container, method = "dlib"):
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment