Skip to content
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
24 changes: 16 additions & 8 deletions src/superannotate/lib/core/video_convertor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ def _interpolate(
"x": round(data["x"] + steps["x"] * idx, 2),
"y": round(data["y"] + steps["y"] * idx, 2),
}
elif annotation_type != AnnotationTypes.EVENT:
tmp_data["points"] = data["points"]
elif (
annotation_type != AnnotationTypes.EVENT
): # AnnotationTypes.POLYGON, AnnotationTypes.POLYLINE
tmp_data["points"] = []
for i in range(len(data["points"])):
tmp_data["points"].append(data["points"][i] + idx * steps[i])

annotations[frame_idx] = Annotation(
instanceId=instance_id,
Expand Down Expand Up @@ -157,12 +161,16 @@ def _interpolate_frames(
"y": (to_frame["y"] - from_frame["y"]) / frames_diff,
}
elif annotation_type in (AnnotationTypes.POLYGON, AnnotationTypes.POLYLINE):
steps = [
(to_point - from_point) / frames_diff
for from_point, to_point in zip(
from_frame["points"], to_frame["points"]
)
]
if len(from_frame["points"]) == len(to_frame["points"]):
steps = [
(to_point - from_point) / frames_diff
for from_point, to_point in zip(
from_frame["points"], to_frame["points"]
)
]
else:
steps = [0] * len(from_frame["points"])

return self._interpolate(
class_name=class_name,
class_id=class_id,
Expand Down
90 changes: 90 additions & 0 deletions tests/data_set/unit/one_frame_video_annotation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"metadata": {
"width": 992,
"height": 568,
"duration": 6.5,
"name": null,
"lastAction": {
"timestamp": 1680778235176,
"email": "karen@superannotate.com"
}
},
"instances": [
{
"id": "MzE4NzcuODYwMzQ2Nzc5NTg=",
"type": "bbox",
"classId": -1,
"createdBy": {
"email": "karen@superannotate.com",
"role": "Admin"
},
"createdAt": "2023-04-06T10:49:58.410Z",
"updatedBy": {
"email": "karen@superannotate.com",
"role": "Admin"
},
"updatedAt": "2023-04-06T10:49:59.799Z",
"locked": false,
"timeline": {
"0": {
"active": true,
"points": {
"x1": 161.52,
"y1": 82,
"x2": 372.8,
"y2": 318.92
}
},
"0.100000": {
"active": false,
"points": {
"x1": 161.52,
"y1": 82,
"x2": 372.8,
"y2": 318.92
}
}
},
"pointLabels": {}
},
{
"id": "NDEyMDguNzUwNzYwMDc4MjU2",
"type": "bbox",
"classId": -1,
"createdBy": {
"email": "karen@superannotate.com",
"role": "Admin"
},
"createdAt": "2023-04-06T10:50:07.741Z",
"updatedBy": {
"email": "karen@superannotate.com",
"role": "Admin"
},
"updatedAt": "2023-04-06T10:50:09.264Z",
"locked": false,
"timeline": {
"0.900001": {
"active": true,
"points": {
"x1": 186.35,
"y1": 164.85,
"x2": 375.17,
"y2": 366.01
}
},
"1.000000": {
"active": false,
"points": {
"x1": 186.35,
"y1": 164.85,
"x2": 375.17,
"y2": 366.01
}
}
},
"pointLabels": {}
}
],
"tags": [],
"name": "ernest mtom 10 fps"
}
Loading