MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / sanitize_bbox

Function sanitize_bbox

util/preprocessing.py:47–58  ·  view source on GitHub ↗
(bbox, img_width, img_height)

Source from the content-addressed store, hash-verified

45
46
47def sanitize_bbox(bbox, img_width, img_height):
48 x, y, w, h = bbox
49 x1 = np.max((0, x))
50 y1 = np.max((0, y))
51 x2 = np.min((img_width - 1, x1 + np.max((0, w - 1))))
52 y2 = np.min((img_height - 1, y1 + np.max((0, h - 1))))
53 if w > 0 and h > 0 and x2 >= x1 and y2 >= y1:
54 bbox = np.array([x1, y1, x2 - x1 + 1, y2 - y1 + 1])
55 else:
56 bbox = None
57
58 return bbox
59def resize(ori_shape, size, max_size=None):
60 # size can be min_size (scalar) or (w, h) tuple
61 # import ipdb; ipdb.set_trace(context=15)

Callers 1

process_bboxFunction · 0.85

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected