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 interpolation error #1878

Merged
merged 2 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
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)