MCPcopy Create free account
hub / github.com/MotrixLab/ADHMR / box_transform

Function box_transform

ADHMR/lib/utils/transforms.py:15–35  ·  view source on GitHub ↗

Random scaling.

(bbox, sf, imgwidth, imght, train)

Source from the content-addressed store, hash-verified

13
14
15def box_transform(bbox, sf, imgwidth, imght, train):
16 """Random scaling."""
17 width = bbox[2] - bbox[0]
18 ht = bbox[3] - bbox[1]
19 if train:
20 scaleRate = 0.25 * np.clip(np.random.randn() * sf, - sf, sf)
21
22 bbox[0] = max(0, bbox[0] - width * scaleRate / 2)
23 bbox[1] = max(0, bbox[1] - ht * scaleRate / 2)
24 bbox[2] = min(imgwidth, bbox[2] + width * scaleRate / 2)
25 bbox[3] = min(imght, bbox[3] + ht * scaleRate / 2)
26 else:
27 scaleRate = 0.25
28
29 bbox[0] = max(0, bbox[0] - width * scaleRate / 2)
30 bbox[1] = max(0, bbox[1] - ht * scaleRate / 2)
31 bbox[2] = min(imgwidth, max(
32 bbox[2] + width * scaleRate / 2, bbox[0] + 5))
33 bbox[3] = min(imght, max(bbox[3] + ht * scaleRate / 2, bbox[1] + 5))
34
35 return bbox
36
37
38def addDPG(bbox, imgwidth, imght):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected