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

Function get_affine_transform

ADHMR/lib/utils/transforms.py:1336–1369  ·  view source on GitHub ↗
(center,
                         scale,
                         rot,
                         output_size,
                         shift=np.array([0, 0], dtype=np.float32),
                         inv=0)

Source from the content-addressed store, hash-verified

1334
1335
1336def get_affine_transform(center,
1337 scale,
1338 rot,
1339 output_size,
1340 shift=np.array([0, 0], dtype=np.float32),
1341 inv=0):
1342 if not isinstance(scale, np.ndarray) and not isinstance(scale, list):
1343 scale = np.array([scale, scale])
1344
1345 scale_tmp = scale
1346 src_w = scale_tmp[0]
1347 dst_w = output_size[0]
1348 dst_h = output_size[1]
1349
1350 rot_rad = np.pi * rot / 180
1351 src_dir = get_dir([0, src_w * -0.5], rot_rad)
1352 dst_dir = np.array([0, dst_w * -0.5], np.float32)
1353
1354 src = np.zeros((3, 2), dtype=np.float32)
1355 dst = np.zeros((3, 2), dtype=np.float32)
1356 src[0, :] = center + scale_tmp * shift
1357 src[1, :] = center + src_dir + scale_tmp * shift
1358 dst[0, :] = [dst_w * 0.5, dst_h * 0.5]
1359 dst[1, :] = np.array([dst_w * 0.5, dst_h * 0.5]) + dst_dir
1360
1361 src[2:, :] = get_3rd_point(src[0, :], src[1, :])
1362 dst[2:, :] = get_3rd_point(dst[0, :], dst[1, :])
1363
1364 if inv:
1365 trans = cv2.getAffineTransform(np.float32(dst), np.float32(src))
1366 else:
1367 trans = cv2.getAffineTransform(np.float32(src), np.float32(dst))
1368
1369 return trans
1370
1371
1372def get_affine_transform_new(center,

Callers 15

__getitem__Method · 0.90
transform_predsFunction · 0.70
test_transformMethod · 0.50
__call__Method · 0.50
test_transformMethod · 0.50
__call__Method · 0.50
test_transformMethod · 0.50
__call__Method · 0.50
test_transformMethod · 0.50
__call__Method · 0.50
test_transformMethod · 0.50
__call__Method · 0.50

Calls 2

get_dirFunction · 0.85
get_3rd_pointFunction · 0.85

Tested by 7

test_transformMethod · 0.40
test_transformMethod · 0.40
test_transformMethod · 0.40
test_transformMethod · 0.40
test_transformMethod · 0.40
test_transformMethod · 0.40
test_transformMethod · 0.40