Skip to content

Commit 7d4c516

Browse files
committed
Add lidar support
1 parent 144146c commit 7d4c516

File tree

8 files changed

+365
-7
lines changed

8 files changed

+365
-7
lines changed

src/superannotate/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
import typing
55

6-
__version__ = "4.4.10"
6+
__version__ = "4.4.11-alpha"
77

88
sys.path.append(os.path.split(os.path.realpath(__file__))[0])
99

src/superannotate/lib/core/enums.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ class ProjectType(BaseTitledEnum):
9898
def images(self):
9999
return self.VECTOR.value, self.PIXEL.value, self.TILED.value
100100

101+
@classproperty
102+
def unsupported_types(cls):
103+
return cls.POINT_CLOUD.value, cls.OTHER.value
104+
101105

102106
class UserRole(BaseTitledEnum):
103107
SUPER_ADMIN = "Superadmin", 1 # noqa

src/superannotate/lib/core/usecases/annotations.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ def get_annotation_from_s3(bucket, path: str):
520520

521521
def prepare_annotation(self, annotation: dict, size) -> dict:
522522
errors = None
523+
if self._project.type == constants.ProjectType.POINT_CLOUD.value:
524+
return annotation
523525
if size < BIG_FILE_THRESHOLD:
524526
use_case = ValidateAnnotationUseCase(
525527
reporter=self.reporter,
@@ -664,6 +666,12 @@ async def distribute_queues(self, items_to_upload: List[ItemToUpload]):
664666
json.dump(annotation, item_to_upload.file)
665667
item_to_upload.file.seek(0)
666668
while True:
669+
if (
670+
self._project.type
671+
== constants.ProjectType.POINT_CLOUD.value
672+
):
673+
self._big_files_queue.put_nowait(item_to_upload)
674+
break
667675
if item_to_upload.file_size > BIG_FILE_THRESHOLD:
668676
if self._big_files_queue.qsize() > 32:
669677
await asyncio.sleep(3)
@@ -1414,13 +1422,13 @@ def validate_item_names(self):
14141422
def _prettify_annotations(self, annotations: List[dict]):
14151423
re_struct = {}
14161424
if self._item_names:
1417-
for annotation in annotations:
1418-
re_struct[annotation["metadata"]["name"]] = annotation
14191425
try:
1426+
for annotation in annotations:
1427+
re_struct[annotation["metadata"]["name"]] = annotation
14201428
return [re_struct[x] for x in self._item_names if x in re_struct]
14211429
except KeyError:
1422-
raise AppException("Broken data.")
1423-
1430+
if self._project.type not in constants.ProjectType.unsupported_types:
1431+
raise AppException("Broken data.")
14241432
return annotations
14251433

14261434
async def get_big_annotation(self):
@@ -1553,6 +1561,7 @@ def execute(self):
15531561
nest_asyncio.apply()
15541562
annotations = asyncio.run(self.run_workers(large_items, small_items))
15551563
except Exception as e:
1564+
raise e
15561565
logger.error(e)
15571566
self._response.errors = AppException("Can't get annotations.")
15581567
return self._response
@@ -1587,6 +1596,12 @@ def __init__(
15871596
self._big_file_queue = None
15881597
self._small_file_queue = None
15891598

1599+
def validate_project_type(self):
1600+
if self._project.type == constants.ProjectType.POINT_CLOUD.value:
1601+
raise AppException(
1602+
f"The function is not supported for {constants.ProjectType(self._project.type).name} projects."
1603+
)
1604+
15901605
def validate_item_names(self):
15911606
if self._item_names:
15921607
item_names = list(dict.fromkeys(self._item_names))
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"000950": [
3+
{
4+
"psr": {
5+
"position": {
6+
"x": -5.080617901849534,
7+
"y": 4.7485066265361535,
8+
"z": -0.5211173295974731
9+
},
10+
"scale": {
11+
"x": 10.438753155962607,
12+
"y": 7.852290496368532,
13+
"z": 3.3729794025421143
14+
},
15+
"rotation": {
16+
"x": 0,
17+
"y": 0,
18+
"z": 1.9247371622914418
19+
}
20+
},
21+
"obj_type": "Personal vehicle",
22+
"obj_id": "1"
23+
},
24+
{
25+
"psr": {
26+
"position": {
27+
"x": 15.25457933415853,
28+
"y": -7.289155780814713,
29+
"z": 0.3909074068069458
30+
},
31+
"scale": {
32+
"x": 16.67372701148617,
33+
"y": 12.997588199926543,
34+
"z": 5.432509660720825
35+
},
36+
"rotation": {
37+
"x": 0,
38+
"y": 0,
39+
"z": 2.993572126346171
40+
}
41+
},
42+
"obj_type": "Personal vehicle",
43+
"obj_id": "2"
44+
}
45+
],
46+
"000965": [
47+
{
48+
"psr": {
49+
"position": {
50+
"x": 12.678969509007786,
51+
"y": -12.72550632620182,
52+
"z": -0.5258613526821136
53+
},
54+
"scale": {
55+
"x": 14.873953074212206,
56+
"y": 9.01690452224452,
57+
"z": 2.72206574678421
58+
},
59+
"rotation": {
60+
"x": 0,
61+
"y": 0,
62+
"z": 2.99357212634617
63+
}
64+
},
65+
"obj_type": "Personal vehicle",
66+
"obj_id": "3"
67+
},
68+
{
69+
"psr": {
70+
"position": {
71+
"x": 14.04525345440314,
72+
"y": 3.6402911227157486,
73+
"z": -0.04190933704376221
74+
},
75+
"scale": {
76+
"x": 10.071495305599894,
77+
"y": 7.171325113558155,
78+
"z": 5.090493440628052
79+
},
80+
"rotation": {
81+
"x": 0,
82+
"y": 0,
83+
"z": -2.6580474313269304
84+
}
85+
},
86+
"obj_type": "Personal vehicle",
87+
"obj_id": "4"
88+
}
89+
],
90+
"000970": [
91+
{
92+
"psr": {
93+
"position": {
94+
"x": 2.4613493554371804,
95+
"y": 8.947661626313172,
96+
"z": 0.21572160720825195
97+
},
98+
"scale": {
99+
"x": 62.35026185183082,
100+
"y": 97.18034925311514,
101+
"z": 8.726404190063477
102+
},
103+
"rotation": {
104+
"x": 0,
105+
"y": 0,
106+
"z": -2.6580474313269304
107+
}
108+
},
109+
"obj_type": "Personal vehicle",
110+
"obj_id": "5"
111+
}
112+
],
113+
"000975": [
114+
{
115+
"psr": {
116+
"position": {
117+
"x": 13.960599950371503,
118+
"y": 0.7873128198567101,
119+
"z": -1.5273447930812836
120+
},
121+
"scale": {
122+
"x": 20.379303339511864,
123+
"y": 14.074981597535814,
124+
"z": 2.112749397754669
125+
},
126+
"rotation": {
127+
"x": 0,
128+
"y": 0,
129+
"z": -0.39218261369803376
130+
}
131+
},
132+
"obj_type": "Default",
133+
"obj_id": "6"
134+
}
135+
]
136+
}
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
[
2+
{
3+
"id": 55917,
4+
"project_id": 11979,
5+
"name": "Personal vehicle",
6+
"color": "#ecb65f",
7+
"count": 25,
8+
"createdAt": "2020-10-12T11:35:20.000Z",
9+
"updatedAt": "2020-10-12T11:48:19.000Z",
10+
"attribute_groups": [
11+
{
12+
"id": 17245,
13+
"class_id": 55917,
14+
"name": "Num doors",
15+
"is_multiselect": 0,
16+
"createdAt": "2020-10-12T11:35:20.000Z",
17+
"updatedAt": "2020-10-12T11:35:20.000Z",
18+
"attributes": [
19+
{
20+
"id": 62792,
21+
"group_id": 17245,
22+
"project_id": 11979,
23+
"name": "2",
24+
"count": 1,
25+
"createdAt": "2020-10-12T11:35:20.000Z",
26+
"updatedAt": "2020-10-12T11:46:28.000Z"
27+
},
28+
{
29+
"id": 62793,
30+
"group_id": 17245,
31+
"project_id": 11979,
32+
"name": "4",
33+
"count": 1,
34+
"createdAt": "2020-10-12T11:35:20.000Z",
35+
"updatedAt": "2020-10-12T11:35:20.000Z"
36+
}
37+
]
38+
}
39+
]
40+
},
41+
{
42+
"id": 55918,
43+
"project_id": 11979,
44+
"name": "Large vehicle",
45+
"color": "#737b28",
46+
"count": 1,
47+
"createdAt": "2020-10-12T11:35:20.000Z",
48+
"updatedAt": "2020-10-12T11:48:19.000Z",
49+
"attribute_groups": [
50+
{
51+
"id": 17246,
52+
"class_id": 55918,
53+
"name": "swedish",
54+
"is_multiselect": 0,
55+
"createdAt": "2020-10-12T11:35:20.000Z",
56+
"updatedAt": "2020-10-12T11:35:20.000Z",
57+
"attributes": [
58+
{
59+
"id": 62794,
60+
"group_id": 17246,
61+
"project_id": 11979,
62+
"name": "yes",
63+
"count": 0,
64+
"createdAt": "2020-10-12T11:35:20.000Z",
65+
"updatedAt": "2020-10-12T11:35:20.000Z"
66+
},
67+
{
68+
"id": 62795,
69+
"group_id": 17246,
70+
"project_id": 11979,
71+
"name": "no",
72+
"count": 1,
73+
"createdAt": "2020-10-12T11:35:20.000Z",
74+
"updatedAt": "2020-10-12T11:46:28.000Z"
75+
}
76+
]
77+
},
78+
{
79+
"id": 17247,
80+
"class_id": 55918,
81+
"name": "Num doors",
82+
"is_multiselect": 0,
83+
"createdAt": "2020-10-12T11:35:20.000Z",
84+
"updatedAt": "2020-10-12T11:35:20.000Z",
85+
"attributes": [
86+
{
87+
"id": 62796,
88+
"group_id": 17247,
89+
"project_id": 11979,
90+
"name": "2",
91+
"count": 0,
92+
"createdAt": "2020-10-12T11:35:20.000Z",
93+
"updatedAt": "2020-10-12T11:35:20.000Z"
94+
},
95+
{
96+
"id": 62797,
97+
"group_id": 17247,
98+
"project_id": 11979,
99+
"name": "4",
100+
"count": 1,
101+
"createdAt": "2020-10-12T11:35:20.000Z",
102+
"updatedAt": "2020-10-12T11:46:28.000Z"
103+
}
104+
]
105+
}
106+
]
107+
},
108+
{
109+
"id": 55919,
110+
"project_id": 11979,
111+
"name": "Human",
112+
"color": "#e4542b",
113+
"count": 9,
114+
"createdAt": "2020-10-12T11:35:20.000Z",
115+
"updatedAt": "2020-10-12T11:48:14.000Z",
116+
"attribute_groups": [
117+
{
118+
"id": 17248,
119+
"class_id": 55919,
120+
"name": "Height",
121+
"is_multiselect": 0,
122+
"createdAt": "2020-10-12T11:35:20.000Z",
123+
"updatedAt": "2020-10-12T11:35:20.000Z",
124+
"attributes": [
125+
{
126+
"id": 62798,
127+
"group_id": 17248,
128+
"project_id": 11979,
129+
"name": "Tall",
130+
"count": 0,
131+
"createdAt": "2020-10-12T11:35:20.000Z",
132+
"updatedAt": "2020-10-12T11:35:20.000Z"
133+
},
134+
{
135+
"id": 62799,
136+
"group_id": 17248,
137+
"project_id": 11979,
138+
"name": "Short",
139+
"count": 0,
140+
"createdAt": "2020-10-12T11:35:20.000Z",
141+
"updatedAt": "2020-10-12T11:35:20.000Z"
142+
}
143+
]
144+
}
145+
]
146+
},
147+
{
148+
"id": 55920,
149+
"project_id": 11979,
150+
"name": "Plant",
151+
"color": "#46ccb2",
152+
"count": 0,
153+
"createdAt": "2020-10-12T11:35:20.000Z",
154+
"updatedAt": "2020-10-12T11:35:20.000Z",
155+
"attribute_groups": []
156+
}
157+
]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
url,name
2+
https://sa-public-text-files.s3.us-west-2.amazonaws.com/davitb/lidar/data/3d_item_1.json,3d_item_1

0 commit comments

Comments
 (0)