Skip to content

Commit 7e41ad8

Browse files
authored
Merge pull request #598 from superannotateai/1894_per_frame_convertor
Updated PerFrame convertor
2 parents 4c0340c + ebf053c commit 7e41ad8

File tree

4 files changed

+877
-8
lines changed

4 files changed

+877
-8
lines changed

src/superannotate/lib/core/video_convertor.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,12 @@ def _interpolate(
7474
"x": round(data["x"] + steps["x"] * idx, 2),
7575
"y": round(data["y"] + steps["y"] * idx, 2),
7676
}
77-
elif annotation_type != AnnotationTypes.EVENT:
78-
tmp_data["points"] = data["points"]
77+
elif (
78+
annotation_type != AnnotationTypes.EVENT
79+
): # AnnotationTypes.POLYGON, AnnotationTypes.POLYLINE
80+
tmp_data["points"] = []
81+
for i in range(len(data["points"])):
82+
tmp_data["points"].append(data["points"][i] + idx * steps[i])
7983

8084
annotations[frame_idx] = Annotation(
8185
instanceId=instance_id,
@@ -157,12 +161,16 @@ def _interpolate_frames(
157161
"y": (to_frame["y"] - from_frame["y"]) / frames_diff,
158162
}
159163
elif annotation_type in (AnnotationTypes.POLYGON, AnnotationTypes.POLYLINE):
160-
steps = [
161-
(to_point - from_point) / frames_diff
162-
for from_point, to_point in zip(
163-
from_frame["points"], to_frame["points"]
164-
)
165-
]
164+
if len(from_frame["points"]) == len(to_frame["points"]):
165+
steps = [
166+
(to_point - from_point) / frames_diff
167+
for from_point, to_point in zip(
168+
from_frame["points"], to_frame["points"]
169+
)
170+
]
171+
else:
172+
steps = [0] * len(from_frame["points"])
173+
166174
return self._interpolate(
167175
class_name=class_name,
168176
class_id=class_id,
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"metadata": {
3+
"width": 992,
4+
"height": 568,
5+
"duration": 6.5,
6+
"name": null,
7+
"lastAction": {
8+
"timestamp": 1680778235176,
9+
"email": "karen@superannotate.com"
10+
}
11+
},
12+
"instances": [
13+
{
14+
"id": "MzE4NzcuODYwMzQ2Nzc5NTg=",
15+
"type": "bbox",
16+
"classId": -1,
17+
"createdBy": {
18+
"email": "karen@superannotate.com",
19+
"role": "Admin"
20+
},
21+
"createdAt": "2023-04-06T10:49:58.410Z",
22+
"updatedBy": {
23+
"email": "karen@superannotate.com",
24+
"role": "Admin"
25+
},
26+
"updatedAt": "2023-04-06T10:49:59.799Z",
27+
"locked": false,
28+
"timeline": {
29+
"0": {
30+
"active": true,
31+
"points": {
32+
"x1": 161.52,
33+
"y1": 82,
34+
"x2": 372.8,
35+
"y2": 318.92
36+
}
37+
},
38+
"0.100000": {
39+
"active": false,
40+
"points": {
41+
"x1": 161.52,
42+
"y1": 82,
43+
"x2": 372.8,
44+
"y2": 318.92
45+
}
46+
}
47+
},
48+
"pointLabels": {}
49+
},
50+
{
51+
"id": "NDEyMDguNzUwNzYwMDc4MjU2",
52+
"type": "bbox",
53+
"classId": -1,
54+
"createdBy": {
55+
"email": "karen@superannotate.com",
56+
"role": "Admin"
57+
},
58+
"createdAt": "2023-04-06T10:50:07.741Z",
59+
"updatedBy": {
60+
"email": "karen@superannotate.com",
61+
"role": "Admin"
62+
},
63+
"updatedAt": "2023-04-06T10:50:09.264Z",
64+
"locked": false,
65+
"timeline": {
66+
"0.900001": {
67+
"active": true,
68+
"points": {
69+
"x1": 186.35,
70+
"y1": 164.85,
71+
"x2": 375.17,
72+
"y2": 366.01
73+
}
74+
},
75+
"1.000000": {
76+
"active": false,
77+
"points": {
78+
"x1": 186.35,
79+
"y1": 164.85,
80+
"x2": 375.17,
81+
"y2": 366.01
82+
}
83+
}
84+
},
85+
"pointLabels": {}
86+
}
87+
],
88+
"tags": [],
89+
"name": "ernest mtom 10 fps"
90+
}

0 commit comments

Comments
 (0)