MCPcopy Index your code
hub / github.com/facebookresearch/ImageBind / crop_boxes

Function crop_boxes

imagebind/data.py:168–184  ·  view source on GitHub ↗

Perform crop on the bounding boxes given the offsets. Args: boxes (ndarray or None): bounding boxes to perform crop. The dimension is `num boxes` x 4. x_offset (int): cropping offset in the x axis. y_offset (int): cropping offset in the y axis. Return

(boxes, x_offset, y_offset)

Source from the content-addressed store, hash-verified

166
167
168def crop_boxes(boxes, x_offset, y_offset):
169 """
170 Perform crop on the bounding boxes given the offsets.
171 Args:
172 boxes (ndarray or None): bounding boxes to perform crop. The dimension
173 is `num boxes` x 4.
174 x_offset (int): cropping offset in the x axis.
175 y_offset (int): cropping offset in the y axis.
176 Returns:
177 cropped_boxes (ndarray or None): the cropped boxes with dimension of
178 `num boxes` x 4.
179 """
180 cropped_boxes = boxes.copy()
181 cropped_boxes[:, [0, 2]] = boxes[:, [0, 2]] - x_offset
182 cropped_boxes[:, [1, 3]] = boxes[:, [1, 3]] - y_offset
183
184 return cropped_boxes
185
186
187def uniform_crop(images, size, spatial_idx, boxes=None, scale_size=None):

Callers 1

uniform_cropFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected