diff --git a/src/model_api/models/utils.py b/src/model_api/models/utils.py index e02b77bb..c362daf2 100644 --- a/src/model_api/models/utils.py +++ b/src/model_api/models/utils.py @@ -124,7 +124,16 @@ def add_rotated_rects(inst_seg_result: InstanceSegmentationResult) -> RotatedSeg # Check if contours were found before processing if contours: contour = np.vstack(contours) - objects_with_rects.append(cv2.minAreaRect(contour)) + rotated_rect = cv2.minAreaRect(contour) + # Adjust angle to be in (0, 90] range + (cx, cy), (w, h), angle = rotated_rect + while angle <= 0: + (w, h) = (h, w) + angle += 90 + while angle > 90: + (w, h) = (h, w) + angle -= 90 + objects_with_rects.append(((cx, cy), (w, h), angle)) else: objects_with_rects.append(((0, 0), (0, 0), 0)) return RotatedSegmentationResult( diff --git a/tests/accuracy/public_scope.json b/tests/accuracy/public_scope.json index 5be791c2..554dfa68 100644 --- a/tests/accuracy/public_scope.json +++ b/tests/accuracy/public_scope.json @@ -641,7 +641,7 @@ { "image": "coco128/images/train2017/000000000074.jpg", "reference": [ - "61, 277, 358, 382, 17 (horse): 0.998, 18312, RotatedRect: 212.000 327.000 290.000 100.000 0.000; 1, 14, 162, 321, 2 (car): 0.994, 25867, RotatedRect: 54.067 173.034 285.208 156.889 61.996; 327, 96, 341, 134, 1 (bicycle): 0.930, 279, RotatedRect: 333.500 114.000 36.000 13.000 90.000; 460, 106, 493, 148, 1 (bicycle): 0.898, 786, RotatedRect: 476.284 126.621 27.308 45.993 19.179; 294, 93, 315, 153, 1 (bicycle): 0.869, 789, RotatedRect: 304.000 124.000 58.000 18.000 90.000; 278, 109, 290, 152, 1 (bicycle): 0.817, 355, RotatedRect: 283.500 130.000 42.000 11.000 90.000; 4, 4, 102, 191, 2 (car): 0.701, 9658, RotatedRect: 51.806 97.259 184.445 95.281 89.246; 270, 93, 290, 152, 1 (bicycle): 0.660, 723, RotatedRect: 280.500 122.500 17.000 59.000 0.000; 322, 114, 343, 152, 18 (sheep): 0.520, 298, RotatedRect: 332.000 133.000 34.000 14.000 90.000; 4; [1,1280,1,1]; " + "61, 277, 358, 382, 17 (horse): 0.998, 18312, RotatedRect: 212.000 327.000 100.000 290.000 90.000; 1, 14, 162, 321, 2 (car): 0.994, 25867, RotatedRect: 54.067 173.034 285.208 156.889 61.996; 327, 96, 341, 134, 1 (bicycle): 0.930, 279, RotatedRect: 333.500 114.000 36.000 13.000 90.000; 460, 106, 493, 148, 1 (bicycle): 0.898, 786, RotatedRect: 476.284 126.621 27.308 45.993 19.179; 294, 93, 315, 153, 1 (bicycle): 0.869, 789, RotatedRect: 304.000 124.000 58.000 18.000 90.000; 278, 109, 290, 152, 1 (bicycle): 0.817, 355, RotatedRect: 283.500 130.000 42.000 11.000 90.000; 4, 4, 102, 191, 2 (car): 0.701, 9658, RotatedRect: 51.806 97.259 184.445 95.281 89.246; 270, 93, 290, 152, 1 (bicycle): 0.660, 723, RotatedRect: 280.500 122.500 59.000 17.000 90.000; 322, 114, 343, 152, 18 (sheep): 0.520, 298, RotatedRect: 332.000 133.000 34.000 14.000 90.000; 4; [1,1280,1,1]; " ] } ]