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
a21eb531
Commit
a21eb531
authored
6 years ago
by
Guillaume HEUSCH
Browse files
Options
Downloads
Patches
Plain Diff
[preprocessor] fixed the exception catching when landmarks are not detected
parent
c3c6328b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!71
Debug pulse based pad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/pad/face/preprocessor/LiPulseExtraction.py
+27
-15
27 additions, 15 deletions
bob/pad/face/preprocessor/LiPulseExtraction.py
with
27 additions
and
15 deletions
bob/pad/face/preprocessor/LiPulseExtraction.py
+
27
−
15
View file @
a21eb531
...
...
@@ -117,31 +117,45 @@ class LiPulseExtraction(Preprocessor):
pyplot
.
show
()
# detect landmarks
try
:
ldms
=
detector
(
frame
)
except
TypeError
:
logger
.
warning
(
"
Exception caught -> problems with landmarks
"
)
# looks like one video from replay mobile is upside down !
ldms
=
detector
(
frame
)
if
ldms
is
None
:
logger
.
warning
(
"
Landmarks not detected ...
"
)
# looks like some videos from replay mobile are upside down !
rotated_shape
=
bob
.
ip
.
base
.
rotated_output_shape
(
frame
,
180
)
frame_rotated
=
numpy
.
ndarray
(
rotated_shape
,
dtype
=
numpy
.
float64
)
from
bob.ip.base
import
rotate
bob
.
ip
.
base
.
rotate
(
frame
,
frame_rotated
,
180
)
frame_rotated
=
frame_rotated
.
astype
(
numpy
.
uint8
)
logger
.
warning
(
"
Rotating again ...
"
)
try
:
ldms
=
detector
(
frame_rotated
)
except
TypeError
:
logger
.
warning
(
"
Rotating 180 degrees ...
"
)
# check the rotated frame
if
self
.
debug
:
from
matplotlib
import
pyplot
pyplot
.
imshow
(
numpy
.
rollaxis
(
numpy
.
rollaxis
(
frame_rotated
,
2
),
2
))
pyplot
.
show
()
ldms
=
detector
(
frame_rotated
)
# if landmarks are still not detected, do nothing
if
ldms
is
None
:
ldms
=
previous_ldms
# so do nothing ...
logger
.
warning
(
"
No mask detected in frame {}
"
.
format
(
i
))
face_color
[
i
]
=
[
0
,
0
,
0
]
continue
frame
=
frame_rotated
# landmarks
have not been
detected
:
use the one from previous frame
#
if
landmarks
are still not
detected
,
use the one from previous frame
(if any)
if
ldms
is
None
:
ldms
=
previous_ldms
logger
.
warning
(
"
Frame {}: no landmarks detected, using the ones from previous frame
"
.
format
(
i
))
if
previous_ldms
is
None
:
logger
.
warning
(
"
No mask detected in frame {}
"
.
format
(
i
))
face_color
[
i
]
=
[
0
,
0
,
0
]
continue
else
:
ldms
=
previous_ldms
logger
.
warning
(
"
Frame {}: no landmarks detected, using the ones from previous frame
"
.
format
(
i
))
if
self
.
debug
:
from
matplotlib
import
pyplot
...
...
@@ -153,9 +167,7 @@ class LiPulseExtraction(Preprocessor):
ldms
=
numpy
.
array
(
ldms
)
mask_points
,
mask
=
kp66_to_mask
(
frame
,
ldms
,
self
.
indent
,
self
.
debug
)
face_color
[
i
]
=
compute_average_colors_mask
(
frame
,
mask
,
self
.
debug
)
logger
.
debug
(
"
Face color in frame {} = {}
"
.
format
(
i
,
face_color
[
i
]))
previous_ldms
=
ldms
counter
+=
1
...
...
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