Unverified Commit 0874642f authored by lizz's avatar lizz Committed by GitHub
Browse files

Speed up bbox_clip (#177)

* Speed up bbox_clip

* Update geometry.py
parent d6ce3a2e
...@@ -76,11 +76,10 @@ def bbox_clip(bboxes, img_shape): ...@@ -76,11 +76,10 @@ def bbox_clip(bboxes, img_shape):
ndarray: Clipped bboxes. ndarray: Clipped bboxes.
""" """
assert bboxes.shape[-1] % 4 == 0 assert bboxes.shape[-1] % 4 == 0
clipped_bboxes = np.empty_like(bboxes, dtype=bboxes.dtype) cmin = np.empty(bboxes.shape[-1], dtype=bboxes.dtype)
clipped_bboxes[..., 0::2] = np.maximum( cmin[0::2] = img_shape[1] - 1
np.minimum(bboxes[..., 0::2], img_shape[1] - 1), 0) cmin[1::2] = img_shape[0] - 1
clipped_bboxes[..., 1::2] = np.maximum( clipped_bboxes = np.maximum(np.minimum(bboxes, cmin), 0)
np.minimum(bboxes[..., 1::2], img_shape[0] - 1), 0)
return clipped_bboxes return clipped_bboxes
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment