Skip to content

Commit

Permalink
Fix interpolation error (#1878)
Browse files Browse the repository at this point in the history
* Add interpolation smoke tests

* update changelog
  • Loading branch information
zhiltsov-max authored Jul 10, 2020
1 parent 2a5cfcc commit a46b9c5
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Annotations aren't updated after reopening a task (<https://github.com/opencv/cvat/pull/1753>)
- Labels aren't updated after reopening a task (<https://github.com/opencv/cvat/pull/1753>)
- Canvas isn't fitted after collapsing side panel in attribute annotation mode (<https://github.com/opencv/cvat/pull/1753>)
- Error when interpolating polygons (<https://github.com/opencv/cvat/pull/1878>)

### Security
- SQL injection in Django `CVE-2020-9402` (<https://github.com/opencv/cvat/pull/1657>)
Expand Down
4 changes: 2 additions & 2 deletions cvat/apps/dataset_manager/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,11 @@ def normalize_shape(shape):

@staticmethod
def get_interpolated_shapes(track, start_frame, end_frame):
def copy_shape(source, frame, points = None):
def copy_shape(source, frame, points=None):
copied = deepcopy(source)
copied["keyframe"] = True
copied["frame"] = frame
if points:
if points is not None:
copied["points"] = points
return copied

Expand Down
92 changes: 91 additions & 1 deletion cvat/apps/dataset_manager/tests/test_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class TrackManagerTest(TestCase):
def test_single_point_interpolation(self):
def test_point_interpolation(self):
track = {
"frame": 0,
"label_id": 0,
Expand Down Expand Up @@ -36,4 +36,94 @@ def test_single_point_interpolation(self):

interpolated = TrackManager.get_interpolated_shapes(track, 0, 2)

self.assertEqual(len(interpolated), 3)

def test_polygon_interpolation(self):
track = {
"frame": 0,
"label_id": 0,
"group": None,
"attributes": [],
"shapes": [
{
"frame": 0,
"points": [1.0, 2.0, 3.0, 4.0, 5.0, 2.0],
"type": "polygon",
"occluded": False,
"outside": False,
"attributes": []
},
{
"frame": 2,
"attributes": [],
"points": [3.0, 4.0, 5.0, 6.0, 7.0, 6.0, 4.0, 5.0],
"type": "polygon",
"occluded": False,
"outside": True
},
]
}

interpolated = TrackManager.get_interpolated_shapes(track, 0, 2)

self.assertEqual(len(interpolated), 3)

def test_bbox_interpolation(self):
track = {
"frame": 0,
"label_id": 0,
"group": None,
"attributes": [],
"shapes": [
{
"frame": 0,
"points": [1.0, 2.0, 3.0, 4.0],
"type": "rectangle",
"occluded": False,
"outside": False,
"attributes": []
},
{
"frame": 2,
"attributes": [],
"points": [3.0, 4.0, 5.0, 6.0],
"type": "rectangle",
"occluded": False,
"outside": True
},
]
}

interpolated = TrackManager.get_interpolated_shapes(track, 0, 2)

self.assertEqual(len(interpolated), 3)

def test_line_interpolation(self):
track = {
"frame": 0,
"label_id": 0,
"group": None,
"attributes": [],
"shapes": [
{
"frame": 0,
"points": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0],
"type": "polyline",
"occluded": False,
"outside": False,
"attributes": []
},
{
"frame": 2,
"attributes": [],
"points": [3.0, 4.0, 5.0, 6.0],
"type": "polyline",
"occluded": False,
"outside": True
},
]
}

interpolated = TrackManager.get_interpolated_shapes(track, 0, 2)

self.assertEqual(len(interpolated), 3)

0 comments on commit a46b9c5

Please sign in to comment.