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
a084afd1
Commit
a084afd1
authored
6 years ago
by
Guillaume HEUSCH
Browse files
Options
Downloads
Patches
Plain Diff
[extractor] corrected 2-3 (minor ?) bugs on the feature computation
parent
2a3cadc7
No related branches found
No related tags found
1 merge request
!69
Resolve "Follow-up from "WIP: rPPG as features for PAD""
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/pad/face/extractor/LTSS.py
+20
-4
20 additions, 4 deletions
bob/pad/face/extractor/LTSS.py
with
20 additions
and
4 deletions
bob/pad/face/extractor/LTSS.py
+
20
−
4
View file @
a084afd1
...
@@ -56,7 +56,10 @@ class LTSS(Extractor, object):
...
@@ -56,7 +56,10 @@ class LTSS(Extractor, object):
"""
"""
super
(
LTSS
,
self
).
__init__
(
**
kwargs
)
super
(
LTSS
,
self
).
__init__
(
**
kwargs
)
self
.
framerate
=
framerate
self
.
framerate
=
framerate
# TODO: try to use window size as NFFT - Guillaume HEUSCH, 04-07-2018
self
.
nfft
=
nfft
self
.
nfft
=
nfft
self
.
debug
=
debug
self
.
debug
=
debug
self
.
window_size
=
window_size
self
.
window_size
=
window_size
self
.
concat
=
concat
self
.
concat
=
concat
...
@@ -80,27 +83,40 @@ class LTSS(Extractor, object):
...
@@ -80,27 +83,40 @@ class LTSS(Extractor, object):
# log-magnitude of DFT coefficients
# log-magnitude of DFT coefficients
log_mags
=
[]
log_mags
=
[]
# go through windows
# go through windows
for
w
in
range
(
0
,
(
signal
.
shape
[
0
]
-
self
.
window_size
),
window_stride
):
for
w
in
range
(
0
,
(
signal
.
shape
[
0
]
-
self
.
window_size
),
window_stride
):
# n is even, as a consequence the fft is as follows [y(0), Re(y(1)), Im(y(1)), ..., Re(y(n/2))]
# i.e. each coefficient, except first and last, is represented by two numbers (real + imaginary)
fft
=
rfft
(
signal
[
w
:
w
+
self
.
window_size
],
n
=
self
.
nfft
)
fft
=
rfft
(
signal
[
w
:
w
+
self
.
window_size
],
n
=
self
.
nfft
)
mags
=
numpy
.
zeros
(
int
(
self
.
nfft
/
2
),
dtype
=
numpy
.
float64
)
# XXX : bug was here (no clipping)
# the magnitude is the norm of the complex numbers, so its size is n/2 + 1
mags
=
numpy
.
zeros
((
int
(
self
.
nfft
/
2
)
+
1
),
dtype
=
numpy
.
float64
)
# first coeff is real
if
abs
(
fft
[
0
])
<
1
:
if
abs
(
fft
[
0
])
<
1
:
mags
[
0
]
=
1
mags
[
0
]
=
1
else
:
else
:
mags
[
0
]
=
abs
(
fft
[
0
])
mags
[
0
]
=
abs
(
fft
[
0
])
# XXX
# go through coeffs 2 to n/2
index
=
1
index
=
1
for
i
in
range
(
1
,
(
fft
.
shape
[
0
]
-
1
),
2
):
for
i
in
range
(
1
,
(
fft
.
shape
[
0
]
-
1
),
2
):
mags
[
index
]
=
numpy
.
sqrt
(
fft
[
i
]
**
2
+
fft
[
i
+
1
]
**
2
)
mags
[
index
]
=
numpy
.
sqrt
(
fft
[
i
]
**
2
+
fft
[
i
+
1
]
**
2
)
if
mags
[
index
]
<
1
:
if
mags
[
index
]
<
1
:
mags
[
index
]
=
1
mags
[
index
]
=
1
index
+=
1
index
+=
1
# last coeff is real too
if
abs
(
fft
[
-
1
])
<
1
:
mags
[
index
]
=
1
else
:
mags
[
index
]
=
abs
(
fft
[
-
1
])
log_mags
.
append
(
numpy
.
log
(
mags
))
log_mags
.
append
(
numpy
.
log
(
mags
))
# build final feature
log_mags
=
numpy
.
array
(
log_mags
)
log_mags
=
numpy
.
array
(
log_mags
)
mean
=
numpy
.
mean
(
log_mags
,
axis
=
0
)
mean
=
numpy
.
mean
(
log_mags
,
axis
=
0
)
std
=
numpy
.
std
(
log_mags
,
axis
=
0
)
std
=
numpy
.
std
(
log_mags
,
axis
=
0
)
...
...
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