Skip to content

Commit d8d245b

Browse files
Merge pull request #986 from roboflow/feat/store-bounding-rect-as-detection-polygon
When running bounding_rect update mask and xyxy of source sv.Detections so results can be visualized
2 parents 21f627e + 88d649a commit d8d245b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • inference/core/workflows/core_steps/transformations/bounding_rect

inference/core/workflows/core_steps/transformations/bounding_rect/v1.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ def run(
111111
det.mask[0]
112112
)
113113

114+
det.mask = np.array(
115+
[
116+
sv.polygon_to_mask(
117+
polygon=np.around(rect).astype(np.int32),
118+
resolution_wh=(det.mask[0].shape[1], det.mask[0].shape[0]),
119+
).astype(bool)
120+
]
121+
)
122+
det.xyxy = np.array(
123+
[sv.polygon_to_xyxy(polygon=np.around(rect).astype(np.int32))]
124+
)
125+
114126
det[BOUNDING_RECT_RECT_KEY_IN_SV_DETECTIONS] = np.array(
115127
[rect], dtype=np.float16
116128
)

0 commit comments

Comments
 (0)