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)
| 166 | |
| 167 | |
| 168 | def 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 | |
| 187 | def uniform_crop(images, size, spatial_idx, boxes=None, scale_size=None): |