MCPcopy Create free account
hub / github.com/OpenGVLab/UniFormerV2 / crop_boxes

Function crop_boxes

slowfast/datasets/transform.py:98–114  ·  view source on GitHub ↗

Peform crop on the bounding boxes given the offsets. Args: boxes (ndarray or None): bounding boxes to peform 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. Returns:

(boxes, x_offset, y_offset)

Source from the content-addressed store, hash-verified

96
97
98def crop_boxes(boxes, x_offset, y_offset):
99 """
100 Peform crop on the bounding boxes given the offsets.
101 Args:
102 boxes (ndarray or None): bounding boxes to peform crop. The dimension
103 is `num boxes` x 4.
104 x_offset (int): cropping offset in the x axis.
105 y_offset (int): cropping offset in the y axis.
106 Returns:
107 cropped_boxes (ndarray or None): the cropped boxes with dimension of
108 `num boxes` x 4.
109 """
110 cropped_boxes = boxes.copy()
111 cropped_boxes[:, [0, 2]] = boxes[:, [0, 2]] - x_offset
112 cropped_boxes[:, [1, 3]] = boxes[:, [1, 3]] - y_offset
113
114 return cropped_boxes
115
116
117def random_crop(images, size, boxes=None):

Callers 2

random_cropFunction · 0.70
uniform_cropFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected