@@ -42,6 +42,54 @@ def validate_subclasses(cls, value, field):
42
42
return value
43
43
44
44
45
+ class _TIPoint (BaseModel ):
46
+ coordinates : List [float ]
47
+
48
+
49
+ class LBV1TIPoint (BaseModel ):
50
+ point : _TIPoint
51
+
52
+ def to_common (self ) -> Point :
53
+ lng , lat = self .point .coordinates
54
+ return Point (x = lng , y = lat )
55
+
56
+
57
+ class LBV1TILine (BaseModel ):
58
+ line : List [_TIPoint ]
59
+
60
+ def to_common (self ) -> Line :
61
+ return Line (points = [
62
+ LBV1TIPoint (point = point ).to_common () for point in self .line
63
+ ])
64
+
65
+
66
+ class LBV1TIPolygon (BaseModel ):
67
+ polygon : List [List [_TIPoint ]]
68
+
69
+ def to_common (self ) -> Polygon :
70
+ for inner_list in self .polygon :
71
+ return Polygon (points = [
72
+ LBV1TIPoint (point = point ).to_common () for point in inner_list
73
+ ])
74
+
75
+
76
+ class LBV1TIRectangle (BaseModel ):
77
+ bbox : List [List [_TIPoint ]]
78
+
79
+ def to_common (self ) -> Rectangle :
80
+ inner_list = self .bbox [0 ]
81
+ start = inner_list [0 ]
82
+ end = inner_list [2 ]
83
+ for inner_list in self .bbox :
84
+ return Rectangle (start = LBV1TIPoint (point = start ).to_common (),
85
+ end = LBV1TIPoint (point = end ).to_common ())
86
+
87
+ for inner_list in self .polygon :
88
+ return Polygon (points = [
89
+ LBV1TIPoint (point = point ).to_common () for point in inner_list
90
+ ])
91
+
92
+
45
93
class _Point (BaseModel ):
46
94
x : float
47
95
y : float
@@ -194,7 +242,8 @@ def from_common(cls, text_entity: TextEntity,
194
242
195
243
class LBV1Objects (BaseModel ):
196
244
objects : List [Union [LBV1Line , LBV1Point , LBV1Polygon , LBV1Rectangle ,
197
- LBV1TextEntity , LBV1Mask ]]
245
+ LBV1TextEntity , LBV1Mask , LBV1TIPoint , LBV1TILine ,
246
+ LBV1TIPolygon , LBV1TIRectangle ]]
198
247
199
248
def to_common (self ) -> List [ObjectAnnotation ]:
200
249
objects = [
0 commit comments