Skip to content

Commit

Permalink
Merge pull request #986 from roboflow/feat/store-bounding-rect-as-det…
Browse files Browse the repository at this point in the history
…ection-polygon

When running bounding_rect update mask and xyxy of source sv.Detections so results can be visualized
  • Loading branch information
grzegorz-roboflow authored Jan 29, 2025
2 parents 21f627e + 88d649a commit d8d245b
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ def run(
det.mask[0]
)

det.mask = np.array(
[
sv.polygon_to_mask(
polygon=np.around(rect).astype(np.int32),
resolution_wh=(det.mask[0].shape[1], det.mask[0].shape[0]),
).astype(bool)
]
)
det.xyxy = np.array(
[sv.polygon_to_xyxy(polygon=np.around(rect).astype(np.int32))]
)

det[BOUNDING_RECT_RECT_KEY_IN_SV_DETECTIONS] = np.array(
[rect], dtype=np.float16
)
Expand Down

0 comments on commit d8d245b

Please sign in to comment.