MCPcopy Create free account
hub / github.com/Pixel-Talk/EHM-Tracker / points2bbox

Function points2bbox

src/modules/pixie/utils/array_cropper.py:13–24  ·  view source on GitHub ↗
(points, points_scale=None)

Source from the content-addressed store, hash-verified

11from skimage.transform import estimate_transform, warp, resize, rescale
12
13def 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
26def augment_bbox(center, bbox_size, scale=[1.0, 1.0], trans_scale=0.):
27 trans_scale = (np.random.rand(2)*2 -1) * trans_scale

Callers 1

cropMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected