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
bob
bob.bio.video
Commits
35f3569e
Commit
35f3569e
authored
Mar 06, 2018
by
Amir MOHAMMADI
Browse files
Merge branch 'quality_check' into 'master'
Quality check on the fly See merge request
!32
parents
e9660045
8f163bf4
Pipeline
#17382
passed with stages
in 19 minutes and 4 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/bio/video/preprocessor/Wrapper.py
View file @
35f3569e
...
...
@@ -115,12 +115,13 @@ class Wrapper(bob.bio.base.preprocessor.Preprocessor):
preprocessed : :py:class:`bob.bio.video.FrameContainer`
A frame container that contains the preprocessed frames.
"""
annots
=
None
fc
=
utils
.
FrameContainer
()
for
index
,
frame
,
_
in
frames
:
# if annotations are given, we take them
if
annotations
is
not
None
:
annots
=
annotations
[
index
]
# if annotations are given, and if particular frame annotations are not missing we take them:
annots
=
annotations
[
index
]
if
annotations
is
not
None
and
index
in
annotations
else
None
# preprocess image (by default: detect a face)
preprocessed
=
self
.
preprocessor
(
frame
,
annots
)
...
...
@@ -177,4 +178,4 @@ class Wrapper(bob.bio.base.preprocessor.Preprocessor):
if
self
.
compressed_io
:
return
utils
.
save_compressed
(
frames
,
filename
,
self
.
preprocessor
.
write_data
)
else
:
frames
.
save
(
bob
.
io
.
base
.
HDF5File
(
filename
,
'w'
),
self
.
preprocessor
.
write_data
)
frames
.
save
(
bob
.
io
.
base
.
HDF5File
(
filename
,
'w'
),
self
.
preprocessor
.
write_data
)
\ No newline at end of file
bob/bio/video/test/test_preprocessor.py
View file @
35f3569e
...
...
@@ -42,6 +42,42 @@ def test_annotations():
assert
numpy
.
allclose
(
preprocessed
[
0
][
1
],
bob
.
io
.
base
.
load
(
pkg_resources
.
resource_filename
(
"bob.bio.face.test"
,
"data/cropped.hdf5"
)))
def
test_missing_annotations
():
class
TestPreproc
(
bob
.
bio
.
base
.
preprocessor
.
Preprocessor
):
# ==========================================================================
def
__init__
(
self
):
super
(
TestPreproc
,
self
).
__init__
()
def
__call__
(
self
,
image
,
annotations
=
None
):
if
annotations
is
None
:
return
None
else
:
return
image
.
shape
[
0
]
# load test video
original_path
=
pkg_resources
.
resource_filename
(
"bob.bio.video.test"
,
""
)
video_object
=
bob
.
bio
.
video
.
database
.
VideoBioFile
(
client_id
=
1
,
file_id
=
1
,
path
=
"data/testvideo"
)
frame_selector
=
bob
.
bio
.
video
.
FrameSelector
(
max_number_of_frames
=
4
,
selection_style
=
"first"
)
preprocessor
=
bob
.
bio
.
video
.
preprocessor
.
Wrapper
(
TestPreproc
(),
frame_selector
,
compressed_io
=
False
)
video
=
preprocessor
.
read_original_data
(
video_object
,
original_path
,
".avi"
)
frame_annots
=
{
'bottomright'
:
(
200
,
200
),
'topleft'
:
(
100
,
100
)}
annotations
=
{}
annotations
[
"0"
]
=
frame_annots
annotations
[
"1"
]
=
{}
annotations
[
"3"
]
=
frame_annots
preprocessed_video
=
preprocessor
(
video
,
annotations
)
assert
len
(
preprocessed_video
)
==
3
assert
preprocessed_video
[
0
][
1
]
==
3
assert
[
x
[
0
]
for
x
in
preprocessed_video
]
==
[
'0'
,
'1'
,
'3'
]
def
test_detect
():
# load test video
...
...
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