@@ -8,6 +8,16 @@ def __init__(self, vertex, project_type):
88 self .vertex = vertex
99 self .project_type = project_type
1010
11+ @classmethod
12+ def fromBbox (cls , width , height , points ):
13+ vertices = [
14+ (points [0 ] / width , points [1 ] / height ), # 左上
15+ (points [2 ] / width , points [1 ] / height ), # 右上
16+ (points [0 ] / width , points [3 ] / height ), # 左下
17+ (points [2 ] / width , points [3 ] / height ), # 右下
18+ ]
19+ return VisualInspectionAiFigure (vertices , "bbox" )
20+
1121 # VisualInspectionAiのjsonlを作成する。
1222 def make_jsonl (self ) -> dict :
1323 return {
@@ -44,13 +54,7 @@ def parseBboxJson(cls, bbox_json) -> list[VisualInspectionAiFigure]:
4454 height = bbox_json ["height" ]
4555 for annotation in bbox_json ["annotations" ]:
4656 points = annotation ["points" ]
47- vertices = [
48- (points [0 ] / width , points [1 ] / height ), # 左上
49- (points [2 ] / width , points [1 ] / height ), # 右上
50- (points [0 ] / width , points [3 ] / height ), # 左下
51- (points [2 ] / width , points [3 ] / height ), # 右下
52- ]
53- result .append (VisualInspectionAiFigure (vertices , "bbox" ))
57+ result .append (VisualInspectionAiFigure .fromBbox (width , height , points ))
5458 return result
5559
5660 @classmethod
0 commit comments