MCPcopy
hub / github.com/OpenMotionLab/MotionGPT / estimate_translation

Function estimate_translation

mGPT/utils/geometry_conver.py:432–461  ·  view source on GitHub ↗

This function is borrowed from https://github.com/nkolot/SPIN/utils/geometry.py Find camera translation that brings 3D joints S closest to 2D the corresponding joints_2d. Input: S: (B, 49, 3) 3D joint locations joints: (B, 49, 3) 2D joint locations and confidence Re

(S, joints_2d, focal_length=5000., img_size=224.)

Source from the content-addressed store, hash-verified

430
431
432def estimate_translation(S, joints_2d, focal_length=5000., img_size=224.):
433 """
434 This function is borrowed from https://github.com/nkolot/SPIN/utils/geometry.py
435
436 Find camera translation that brings 3D joints S closest to 2D the corresponding joints_2d.
437 Input:
438 S: (B, 49, 3) 3D joint locations
439 joints: (B, 49, 3) 2D joint locations and confidence
440 Returns:
441 (B, 3) camera translation vectors
442 """
443
444 device = S.device
445 # Use only joints 25:49 (GT joints)
446 S = S[:, 25:, :].cpu().numpy()
447 joints_2d = joints_2d[:, 25:, :].cpu().numpy()
448 joints_conf = joints_2d[:, :, -1]
449 joints_2d = joints_2d[:, :, :-1]
450 trans = np.zeros((S.shape[0], 3), dtype=np.float6432)
451 # Find the translation for each example in the batch
452 for i in range(S.shape[0]):
453 S_i = S[i]
454 joints_i = joints_2d[i]
455 conf_i = joints_conf[i]
456 trans[i] = estimate_translation_np(S_i,
457 joints_i,
458 conf_i,
459 focal_length=focal_length,
460 img_size=img_size)
461 return torch.from_numpy(trans).to(device)
462
463
464def rot6d_to_rotmat_spin(x):

Callers

nothing calls this directly

Calls 2

estimate_translation_npFunction · 0.85
toMethod · 0.45

Tested by

no test coverage detected