Fix interpolation error (#1878)

* Add interpolation smoke tests

* update changelog
main
zhiltsov-max 6 years ago committed by GitHub
parent 2a5cfcc657
commit a46b9c523c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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>)

@ -442,11 +442,11 @@ class TrackManager(ObjectManager):
@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

@ -8,7 +8,7 @@ from unittest import TestCase
class TrackManagerTest(TestCase):
def test_single_point_interpolation(self):
def test_point_interpolation(self):
track = {
"frame": 0,
"label_id": 0,
@ -36,4 +36,94 @@ class TrackManagerTest(TestCase):
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)
Loading…
Cancel
Save