Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/model_api/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Comment thread
tybulewicz marked this conversation as resolved.
(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(
Expand Down
2 changes: 1 addition & 1 deletion tests/accuracy/public_scope.json
Original file line number Diff line number Diff line change
Expand Up @@ -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]; "
]
}
]
Expand Down