Args: points: (nx4)x2 Returns: nx4 boxes (x1y1x2y2)
(points)
| 78 | |
| 79 | |
| 80 | def point4_to_box(points): |
| 81 | """ |
| 82 | Args: |
| 83 | points: (nx4)x2 |
| 84 | Returns: |
| 85 | nx4 boxes (x1y1x2y2) |
| 86 | """ |
| 87 | p = points.reshape((-1, 4, 2)) |
| 88 | minxy = p.min(axis=1) # nx2 |
| 89 | maxxy = p.max(axis=1) # nx2 |
| 90 | return np.concatenate((minxy, maxxy), axis=1) |
| 91 | |
| 92 | |
| 93 | def polygons_to_mask(polys, height, width): |