Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.bio.video
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.bio.video
Commits
ec42a9cf
Commit
ec42a9cf
authored
5 years ago
by
Pavel KORSHUNOV
Browse files
Options
Downloads
Patches
Plain Diff
support selection of neighboring frames
parent
fe242495
No related branches found
No related tags found
No related merge requests found
Pipeline
#35540
failed
5 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/bio/video/utils/FrameSelector.py
+17
-2
17 additions, 2 deletions
bob/bio/video/utils/FrameSelector.py
with
17 additions
and
2 deletions
bob/bio/video/utils/FrameSelector.py
+
17
−
2
View file @
ec42a9cf
...
@@ -30,6 +30,7 @@ class FrameSelector:
...
@@ -30,6 +30,7 @@ class FrameSelector:
def
__init__
(
self
,
def
__init__
(
self
,
max_number_of_frames
=
20
,
max_number_of_frames
=
20
,
selection_style
=
"
spread
"
,
selection_style
=
"
spread
"
,
neighbors
=
1
,
step_size
=
10
step_size
=
10
):
):
if
selection_style
not
in
(
'
first
'
,
'
spread
'
,
'
step
'
,
'
all
'
):
if
selection_style
not
in
(
'
first
'
,
'
spread
'
,
'
step
'
,
'
all
'
):
...
@@ -37,6 +38,9 @@ class FrameSelector:
...
@@ -37,6 +38,9 @@ class FrameSelector:
self
.
selection
=
selection_style
self
.
selection
=
selection_style
self
.
max_frames
=
max_number_of_frames
self
.
max_frames
=
max_number_of_frames
self
.
step
=
step_size
self
.
step
=
step_size
self
.
neighbors
=
neighbors
if
selection_style
==
'
step
'
and
neighbors
>=
(
step_size
-
2
):
self
.
neighbors
=
1
def
__call__
(
self
,
data
,
load_function
=
bob
.
io
.
base
.
load
):
def
__call__
(
self
,
data
,
load_function
=
bob
.
io
.
base
.
load
):
"""
Selects frames and returns them in a FrameContainer.
"""
Selects frames and returns them in a FrameContainer.
...
@@ -56,14 +60,21 @@ class FrameSelector:
...
@@ -56,14 +60,21 @@ class FrameSelector:
# first, get the indices
# first, get the indices
count
=
len
(
data
)
count
=
len
(
data
)
indices
=
None
if
self
.
selection
==
'
first
'
:
if
self
.
selection
==
'
first
'
:
# get the first frames (limited by all frames)
# get the first frames (limited by all frames)
indices
=
range
(
0
,
min
(
count
,
self
.
max_frames
))
indices
=
range
(
0
,
min
(
count
,
self
.
max_frames
))
elif
self
.
selection
==
'
spread
'
:
elif
self
.
selection
==
'
spread
'
:
# get frames lineraly spread over all frames
# get frames lineraly spread over all frames
indices
=
bob
.
bio
.
base
.
selected_indices
(
count
,
self
.
max_frames
)
indices
=
bob
.
bio
.
base
.
selected_indices
(
count
-
self
.
neighbors
+
1
,
self
.
max_frames
)
for
j
in
range
(
self
.
neighbors
-
1
):
indices
+=
[
i
+
1
for
i
in
indices
]
indices
=
sorted
(
indices
)
elif
self
.
selection
==
'
step
'
:
elif
self
.
selection
==
'
step
'
:
indices
=
range
(
self
.
step
//
2
,
count
,
self
.
step
)[:
self
.
max_frames
]
indices
=
range
(
self
.
step
//
2
,
count
-
self
.
neighbors
+
1
,
self
.
step
)[:
self
.
max_frames
]
for
j
in
range
(
self
.
neighbors
-
1
):
indices
+=
[
i
+
1
for
i
in
indices
]
indices
=
sorted
(
indices
)
elif
self
.
selection
==
'
all
'
:
elif
self
.
selection
==
'
all
'
:
indices
=
range
(
0
,
count
)
indices
=
range
(
0
,
count
)
...
@@ -85,6 +96,10 @@ class FrameSelector:
...
@@ -85,6 +96,10 @@ class FrameSelector:
image
=
load_function
(
data
[
i
])
image
=
load_function
(
data
[
i
])
# save image name as well
# save image name as well
fc
.
add
(
os
.
path
.
basename
(
data
[
i
]),
image
)
fc
.
add
(
os
.
path
.
basename
(
data
[
i
]),
image
)
else
:
for
i
,
frame
in
enumerate
(
data
):
if
i
in
indices
:
fc
.
add
(
i
,
frame
)
return
fc
return
fc
...
...
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