Skip to content

Commit

Permalink
Fix point interpolation (#1344)
Browse files Browse the repository at this point in the history
* Extend formats tests with different track types

* Add unordered list comparison

* Skip empty list comparison

* fix

* fix

* Reproduce problem

* Fix point interpolation for single point

* undo rest api refactor
  • Loading branch information
zhiltsov-max authored Apr 2, 2020
1 parent 1feeef6 commit 66c6e7e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cvat/apps/engine/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,10 @@ def _modify_unmached_object(obj, end_frame):

@staticmethod
def normalize_shape(shape):
points = np.asarray(shape["points"]).reshape(-1, 2)
points = list(shape["points"])
if len(points) == 2:
points.extend(points) # duplicate points for single point case
points = np.asarray(points).reshape(-1, 2)
broken_line = geometry.LineString(points)
points = []
for off in range(0, 100, 1):
Expand Down
39 changes: 39 additions & 0 deletions cvat/apps/engine/tests/test_data_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT

from cvat.apps.engine.data_manager import TrackManager

from unittest import TestCase


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

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

self.assertEqual(len(interpolated), 3)

0 comments on commit 66c6e7e

Please sign in to comment.