Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect attribute import in tracks #3229

Merged
merged 6 commits into from
Jun 1, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions cvat/apps/dataset_manager/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ def filter_track_shapes(shapes):
drop_count += 1
else:
break
# Need to leave the last shape if all shapes are outside
if drop_count == len(shapes):
drop_count -= 1

return shapes[drop_count:]

Expand All @@ -103,18 +100,23 @@ def filter_track_shapes(shapes):
if scoped_shapes:
if not scoped_shapes[0]['keyframe']:
segment_shapes.insert(0, scoped_shapes[0])
if not scoped_shapes[-1]['keyframe']:
if not scoped_shapes[-1]['keyframe'] and \
scoped_shapes[-1]['outside']:
segment_shapes.append(scoped_shapes[-1])
elif stop + 1 < len(interpolated_shapes) and \
interpolated_shapes[stop + 1]['outside']:
segment_shapes.append(interpolated_shapes[stop + 1])

# Should delete 'interpolation_shapes' and 'keyframe' keys because
# Track and TrackedShape models don't expect these fields
del track['interpolated_shapes']
for shape in segment_shapes:
shape.pop('keyframe', None)

track['shapes'] = segment_shapes
track['frame'] = track['shapes'][0]['frame']
return track
if 0 < len(segment_shapes):
track['shapes'] = segment_shapes
track['frame'] = track['shapes'][0]['frame']
return track
zhiltsov-max marked this conversation as resolved.
Show resolved Hide resolved

def slice(self, start, stop):
#makes a data copy from specified frame interval
Expand All @@ -123,8 +125,13 @@ def slice(self, start, stop):
for t in self.tags if self._is_shape_inside(t, start, stop)]
splitted_data.shapes = [deepcopy(s)
for s in self.shapes if self._is_shape_inside(s, start, stop)]
splitted_data.tracks = [self._slice_track(t, start, stop)
for t in self.tracks if self._is_track_inside(t, start, stop)]
splitted_tracks = []
for t in self.tracks:
if self._is_track_inside(t, start, stop):
track = self._slice_track(t, start, stop)
if track != None:
splitted_tracks.append(track)
splitted_data.tracks = splitted_tracks

return splitted_data

Expand Down