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)
| 96 | |
| 97 | |
| 98 | def 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 | |
| 117 | def random_crop(images, size, boxes=None): |
no outgoing calls
no test coverage detected