Scale the short side of the box to size. Args: size (int): size to scale the image. boxes (ndarray): bounding boxes to peform scale. The dimension is `num boxes` x 4. height (int): the height of the image. width (int): the width of the image. Retu
(size, boxes, height, width)
| 104 | |
| 105 | |
| 106 | def scale_boxes(size, boxes, height, width): |
| 107 | """ |
| 108 | Scale the short side of the box to size. |
| 109 | Args: |
| 110 | size (int): size to scale the image. |
| 111 | boxes (ndarray): bounding boxes to peform scale. The dimension is |
| 112 | `num boxes` x 4. |
| 113 | height (int): the height of the image. |
| 114 | width (int): the width of the image. |
| 115 | Returns: |
| 116 | boxes (ndarray): scaled bounding boxes. |
| 117 | """ |
| 118 | if (width <= height and width == size) or ( |
| 119 | height <= width and height == size |
| 120 | ): |
| 121 | return boxes |
| 122 | |
| 123 | new_width = size |
| 124 | new_height = size |
| 125 | if width < height: |
| 126 | new_height = int(math.floor((float(height) / width) * size)) |
| 127 | boxes *= float(new_height) / height |
| 128 | else: |
| 129 | new_width = int(math.floor((float(width) / height) * size)) |
| 130 | boxes *= float(new_width) / width |
| 131 | return boxes |
| 132 | |
| 133 | |
| 134 | def horizontal_flip_list(prob, images, order="CHW", boxes=None): |