Skip to content

Commit

Permalink
Fix incorrect attribute import in tracks (#3229)
Browse files Browse the repository at this point in the history
* add fixes

* remove comments

* fix return value in filter_track_shapes

* update changelog
  • Loading branch information
yasakova-anastasia authored Jun 1, 2021
1 parent 573bdbe commit cc4b3f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Project page requests took a long time and did many DB queries (<https://github.com/openvinotoolkit/cvat/pull/3223>)
- Fixed Python 3.6 support (<https://github.com/openvinotoolkit/cvat/pull/3258>)
- Incorrect attribute import in tracks (<https://github.com/openvinotoolkit/cvat/pull/3229>)

### Security

Expand Down
21 changes: 14 additions & 7 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,8 +100,12 @@ 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
Expand All @@ -113,7 +114,8 @@ def filter_track_shapes(shapes):
shape.pop('keyframe', None)

track['shapes'] = segment_shapes
track['frame'] = track['shapes'][0]['frame']
if 0 < len(segment_shapes):
track['frame'] = track['shapes'][0]['frame']
return track

def slice(self, start, stop):
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 0 < len(track['shapes']):
splitted_tracks.append(track)
splitted_data.tracks = splitted_tracks

return splitted_data

Expand Down

0 comments on commit cc4b3f3

Please sign in to comment.