未验证 提交 f52902b8 编写于 作者: A Anastasia Yasakova 提交者: GitHub

Fix redundant writing of skeleton annotations (CVAT for images) (#5387)

Fixed #5279 
上级 4c32be5c
......@@ -152,6 +152,7 @@ non-ascii paths while adding files from "Connected file share" (issue #4428)
- Added force logout on CVAT app start if token is missing (<https://github.com/opencv/cvat/pull/5331>)
- Drawing issues on 3D canvas (<https://github.com/opencv/cvat/pull/5410>)
- Missed token with using social account authentication (<https://github.com/opencv/cvat/pull/5344>)
- Redundant writing of skeleton annotations (CVAT for images) (<https://github.com/opencv/cvat/pull/5387>)
- The same object on 3D scene or `null` selected each click (PERFORMANCE) (<https://github.com/opencv/cvat/pull/5411>)
- An exception when run export for an empty task (<https://github.com/opencv/cvat/pull/5396>)
- Fixed FBRS serverless function runtime error on images with alpha channel (<https://github.com/opencv/cvat/pull/5384>)
......
......@@ -411,29 +411,34 @@ class TrackManager(ObjectManager):
def to_shapes(self, end_frame, end_skeleton_frame=None):
shapes = []
for idx, track in enumerate(self.objects):
track_shapes = []
track_shapes = {}
for shape in TrackManager.get_interpolated_shapes(track, 0, end_frame, self._dimension):
shape["label_id"] = track["label_id"]
shape["group"] = track["group"]
shape["track_id"] = idx
shape["attributes"] += track["attributes"]
shape["elements"] = []
track_shapes.append(shape)
track_shapes[shape["frame"]] = shape
last_frame = shape["frame"]
while end_skeleton_frame and track_shapes[-1]["frame"] < end_skeleton_frame:
shape = deepcopy(track_shapes[-1])
while end_skeleton_frame and shape["frame"] < end_skeleton_frame:
shape = deepcopy(shape)
shape["frame"] += 1
track_shapes.append(shape)
track_shapes[shape["frame"]] = shape
if len(track.get("elements", [])):
element_tracks = TrackManager(track["elements"], self._dimension)
element_shapes = element_tracks.to_shapes(end_frame, end_skeleton_frame=track_shapes[-1]["frame"])
track_elements = TrackManager(track["elements"], self._dimension)
element_shapes = track_elements.to_shapes(end_frame,
end_skeleton_frame=last_frame)
for i in range(len(element_shapes) // len(track_shapes)):
for track_shape, element_shape in zip(track_shapes, element_shapes[len(track_shapes) * i : len(track_shapes) * (i + 1)]):
track_shape["elements"].append(element_shape)
for shape in element_shapes:
track_shapes[shape["frame"]]["elements"].append(shape)
shapes.extend(track_shapes)
for frame, shape in list(track_shapes.items()):
if all([el["outside"] for el in shape["elements"]]):
track_shapes.pop(frame)
shapes.extend(list(track_shapes.values()))
return shapes
@staticmethod
......
......@@ -1823,7 +1823,8 @@ def import_dm_annotations(dm_dataset: dm.Dataset, instance_data: Union[ProjectDa
if ann.type == dm.AnnotationType.skeleton:
for element in ann.elements:
element_keyframe = dm.util.cast(element.attributes.get('keyframe', None), bool) is True
element_outside = dm.util.cast(element.attributes.pop('outside', None), bool) is True
element_occluded = element.visibility[0] == dm.Points.Visibility.hidden
element_outside = element.visibility[0] == dm.Points.Visibility.absent
if not element_keyframe and not element_outside:
continue
......@@ -1838,7 +1839,6 @@ def import_dm_annotations(dm_dataset: dm.Dataset, instance_data: Union[ProjectDa
instance_data.Attribute(name=n, value=str(v))
for n, v in element.attributes.items()
]
element_occluded = dm.util.cast(element.attributes.pop('occluded', None), bool) is True
element_source = element.attributes.pop('source').lower() \
if element.attributes.get('source', '').lower() in {'auto', 'manual'} else 'manual'
tracks[track_id]['elements'][element.label].shapes.append(instance_data.TrackedShape(
......
......@@ -120,8 +120,8 @@ In later releases `polygon`, `polyline`, `points`, `skeletons` and `tags` were a
<attribute name="String: an attribute name">String: the attribute value</attribute>
...
</tag>
<skeleton label="String: the associated label" occluded="Number: 0 - False, 1 - True" z_order="Number: z-order of the object">
<points label="String: the associated label" occluded="Number: 0 - False, 1 - True" outside="Number: 0 - False, 1 - True" points="x0,y0;x1,y1" z_order="0">
<skeleton label="String: the associated label" z_order="Number: z-order of the object">
<points label="String: the associated label" occluded="Number: 0 - False, 1 - True" outside="Number: 0 - False, 1 - True" points="x0,y0;x1,y1">
<attribute name="String: an attribute name">String: the attribute value</attribute>
</points>
...
......@@ -229,12 +229,12 @@ Example:
</points>
<tag label="good_frame" source="manual">
</tag>
<skeleton label="s1" occluded="0" source="manual" points="" rotation="0.00" z_order="0">
<points label="1" occluded="0" source="manual" outside="0" points="54.47,94.81" z_order="0">
<skeleton label="s1" source="manual" z_order="0">
<points label="1" occluded="0" source="manual" outside="0" points="54.47,94.81">
</points>
<points label="2" occluded="0" source="manual" outside="0" points="68.02,162.34" z_order="0">
<points label="2" occluded="0" source="manual" outside="0" points="68.02,162.34">
</points>
<points label="3" occluded="0" source="manual" outside="0" points="125.87,62.85" z_order="0">
<points label="3" occluded="0" source="manual" outside="0" points="125.87,62.85">
</points>
</skeleton>
</image>
......@@ -270,14 +270,11 @@ cloned for each location (a known redundancy).
...
</track>
<track id="Number: id of the track (doesn't have any special meeting)" label="String: the associated label" source="manual or auto">
<skeleton frame="Number: frame" outside="Number: 0 - False, 1 - True" occluded="Number: 0 - False, 1 - True" keyframe="Number: 0 - False, 1 - True">
</skeleton>
...
<track id="Number: id of the track (doesn't have any special meeting)" label="String: the associated label" source="manual or auto">
<points frame="Number: frame" outside="Number: 0 - False, 1 - True" occluded="Number: 0 - False, 1 - True" keyframe="Number: 0 - False, 1 - True" points="x0,y0;x1,y1">
<skeleton frame="Number: frame" keyframe="Number: 0 - False, 1 - True">
<points label="String: the associated label" outside="Number: 0 - False, 1 - True" occluded="Number: 0 - False, 1 - True" keyframe="Number: 0 - False, 1 - True" points="x0,y0;x1,y1">
</points>
...
</track>
</skeleton>
...
</track>
...
......@@ -375,60 +372,54 @@ Example:
</polygon>
</track>
<track id="1" label="s1" source="manual">
<skeleton frame="0" outside="0" occluded="0" keyframe="1" points="" z_order="0">
</skeleton>
<skeleton frame="1" outside="1" occluded="0" keyframe="1" points="" z_order="0">
</skeleton>
<skeleton frame="6" outside="0" occluded="0" keyframe="1" points="" z_order="0">
</skeleton>
<skeleton frame="7" outside="1" occluded="0" keyframe="1" points="" z_order="0">
</skeleton>
<skeleton frame="13" outside="0" occluded="0" keyframe="0" points="" z_order="0">
</skeleton>
<skeleton frame="14" outside="1" occluded="0" keyframe="1" points="" z_order="0">
</skeleton>
<track id="0" label="1" source="manual" task_id="20" subset="default_1">
<points frame="0" outside="0" occluded="0" keyframe="1" points="112.07,258.59" z_order="0">
<skeleton frame="0" keyframe="1" z_order="0">
<points label="1" outside="0" occluded="0" keyframe="1" points="112.07,258.59">
</points>
<points frame="1" outside="1" occluded="0" keyframe="1" points="112.07,258.59" z_order="0">
<points label="2" outside="0" occluded="0" keyframe="1" points="127.87,333.23">
</points>
<points frame="6" outside="0" occluded="0" keyframe="0" points="120.07,270.59" z_order="0">
<points label="3" outside="0" occluded="0" keyframe="1" points="195.37,223.27">
</points>
<points frame="7" outside="1" occluded="0" keyframe="1" points="120.07,270.59" z_order="0">
</skeleton>
<skeleton frame="1" keyframe="1" z_order="0">
<points label="1" outside="1" occluded="0" keyframe="1" points="112.07,258.59">
</points>
<points frame="13" outside="0" occluded="0" keyframe="0" points="112.07,258.59" z_order="0">
<points label="2" outside="1" occluded="0" keyframe="1" points="127.87,333.23">
</points>
<points frame="14" outside="1" occluded="0" keyframe="1" points="112.07,258.59" z_order="0">
<points label="3" outside="1" occluded="0" keyframe="1" points="195.37,223.27">
</points>
</track>
<track id="1" label="2" source="manual" task_id="20" subset="default_1">
<points frame="0" outside="0" occluded="0" keyframe="1" points="127.87,333.23" z_order="0">
</skeleton>
<skeleton frame="6" keyframe="1" z_order="0">
<points label="1" outside="0" occluded="0" keyframe="0" points="120.07,270.59">
</points>
<points frame="1" outside="1" occluded="0" keyframe="1" points="127.87,333.23" z_order="0">
<points label="2" outside="0" occluded="0" keyframe="0" points="140.87,350.23">
</points>
<points frame="6" outside="0" occluded="0" keyframe="0" points="140.87,350.23" z_order="0">
<points label="3" outside="0" occluded="0" keyframe="0" points="210.37,260.27">
</points>
<points frame="7" outside="1" occluded="0" keyframe="1" points="140.87,350.23" z_order="0">
</skeleton>
<skeleton frame="7" keyframe="1" z_order="0">
<points label="1" outside="1" occluded="0" keyframe="1" points="120.07,270.59">
</points>
<points frame="13" outside="0" occluded="0" keyframe="0" points="127.87,333.23" z_order="0">
<points label="2" outside="1" occluded="0" keyframe="1" points="140.87,350.23">
</points>
<points frame="14" outside="1" occluded="0" keyframe="1" points="127.87,333.23" z_order="0">
<points label="3" outside="1" occluded="0" keyframe="1" points="210.37,260.27">
</points>
</track>
<track id="2" label="3" source="manual" task_id="20" subset="default_1">
<points frame="0" outside="0" occluded="0" keyframe="1" points="195.37,223.27" z_order="0">
</skeleton>
<skeleton frame="13" keyframe="0" z_order="0">
<points label="1" outside="0" occluded="0" keyframe="0" points="112.07,258.59">
</points>
<points frame="1" outside="1" occluded="0" keyframe="1" points="195.37,223.27" z_order="0">
<points label="2" outside="0" occluded="0" keyframe="0" points="127.87,333.23">
</points>
<points frame="6" outside="0" occluded="0" keyframe="0" points="210.37,260.27" z_order="0">
<points label="3" outside="0" occluded="0" keyframe="0" points="195.37,223.27">
</points>
<points frame="7" outside="1" occluded="0" keyframe="1" points="210.37,260.27" z_order="0">
</skeleton>
<skeleton frame="14" keyframe="1" z_order="0">
<points label="1" outside="1" occluded="0" keyframe="1" points="112.07,258.59">
</points>
<points frame="13" outside="0" occluded="0" keyframe="0" points="195.37,223.27" z_order="0">
<points label="2" outside="1" occluded="0" keyframe="1" points="127.87,333.23">
</points>
<points frame="14" outside="1" occluded="0" keyframe="1" points="195.37,223.27" z_order="0">
<points label="3" outside="1" occluded="0" keyframe="1" points="195.37,223.27">
</points>
</track>
</skeleton>
</track>
</annotations>
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册