| 11 | from skimage.transform import estimate_transform, warp, resize, rescale |
| 12 | |
| 13 | def points2bbox(points, points_scale=None): |
| 14 | # recover range |
| 15 | if points_scale: |
| 16 | points[:,0] = points[:,0]*points_scale[1]/2 + points_scale[1]/2 |
| 17 | points[:,1] = points[:,1]*points_scale[0]/2 + points_scale[0]/2 |
| 18 | |
| 19 | left = np.min(points[:,0]); right = np.max(points[:,0]); |
| 20 | top = np.min(points[:,1]); bottom = np.max(points[:,1]) |
| 21 | size = max(right - left, bottom - top) |
| 22 | center = np.array([right - (right - left) / 2.0, bottom - (bottom - top) / 2.0 ])#+ old_size*0.1]) |
| 23 | return center, size |
| 24 | # translate center |
| 25 | |
| 26 | def augment_bbox(center, bbox_size, scale=[1.0, 1.0], trans_scale=0.): |
| 27 | trans_scale = (np.random.rand(2)*2 -1) * trans_scale |