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
e588deb4
Commit
e588deb4
authored
Mar 05, 2018
by
Olegs NIKISINS
Browse files
Changed missing annotations conditional check + unit tests
parent
a9962f1a
Pipeline
#17350
passed with stage
in 17 minutes and 32 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/bio/video/preprocessor/Wrapper.py
View file @
e588deb4
...
...
@@ -115,12 +115,14 @@ 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
index
in
annotations
.
keys
()
else
None
annots
=
None
# if annotations are given, and if particular frame annotations are not missing we take them:
if
annotations
is
not
None
and
index
in
annotations
.
keys
()
and
annotations
[
index
]:
annots
=
annotations
[
index
]
# preprocess image (by default: detect a face)
preprocessed
=
self
.
preprocessor
(
frame
,
annots
)
...
...
bob/bio/video/test/test_preprocessor.py
View file @
e588deb4
...
...
@@ -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
)
==
2
assert
preprocessed_video
[
0
][
1
]
==
3
assert
[
x
[
0
]
for
x
in
preprocessed_video
]
==
[
'0'
,
'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