Skip to content
Snippets Groups Projects
Commit 82b7dd9a authored by Pavel KORSHUNOV's avatar Pavel KORSHUNOV
Browse files

corrected indices selection

parent ec42a9cf
Branches update_fs
No related tags found
No related merge requests found
Pipeline #35605 failed
...@@ -42,6 +42,13 @@ class FrameSelector: ...@@ -42,6 +42,13 @@ class FrameSelector:
if selection_style == 'step' and neighbors >= (step_size-2): if selection_style == 'step' and neighbors >= (step_size-2):
self.neighbors = 1 self.neighbors = 1
def _add_indices_neighbors(self, indices):
indices_extended = list()
for j in range(self.neighbors):
indices_extended += [i + j for i in indices]
indices_extended = sorted(list(set(indices_extended)))
return indices_extended
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.
Different ``data`` parameters are accepted: Different ``data`` parameters are accepted:
...@@ -67,14 +74,12 @@ class FrameSelector: ...@@ -67,14 +74,12 @@ class FrameSelector:
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.neighbors+1, self.max_frames) indices = bob.bio.base.selected_indices(count-self.neighbors+1, self.max_frames)
for j in range(self.neighbors-1): if self.neighbors > 1:
indices += [i+1 for i in indices] indices = self._add_indices_neighbors(indices)
indices = sorted(indices)
elif self.selection == 'step': elif self.selection == 'step':
indices = range(self.step//2, count-self.neighbors+1, 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): if self.neighbors > 1:
indices += [i+1 for i in indices] indices = self._add_indices_neighbors(indices)
indices = sorted(indices)
elif self.selection == 'all': elif self.selection == 'all':
indices = range(0, count) indices = range(0, count)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment