MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / estimate_translation

Function estimate_translation

detrsmpl/utils/geometry.py:329–357  ·  view source on GitHub ↗

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 Returns: (B, 3) camera translation vectors

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

Source from the content-addressed store, hash-verified

327
328
329def estimate_translation(S, joints_2d, focal_length=5000., img_size=224.):
330 """Find camera translation that brings 3D joints S closest to 2D the
331 corresponding joints_2d.
332
333 Input:
334 S: (B, 49, 3) 3D joint locations
335 joints: (B, 49, 3) 2D joint locations and confidence
336 Returns:
337 (B, 3) camera translation vectors
338 """
339
340 device = S.device
341 # Use only joints 25:49 (GT joints)
342 S = S[:, 25:, :].cpu().numpy()
343 joints_2d = joints_2d[:, 25:, :].cpu().numpy()
344 joints_conf = joints_2d[:, :, -1]
345 joints_2d = joints_2d[:, :, :-1]
346 trans = np.zeros((S.shape[0], 3), dtype=np.float32)
347 # Find the translation for each example in the batch
348 for i in range(S.shape[0]):
349 S_i = S[i]
350 joints_i = joints_2d[i]
351 conf_i = joints_conf[i]
352 trans[i] = estimate_translation_np(S_i,
353 joints_i,
354 conf_i,
355 focal_length=focal_length,
356 img_size=img_size)
357 return torch.from_numpy(trans).to(device)
358
359
360def project_points(points_3d, camera, focal_length, img_res):

Callers 2

run_registrationMethod · 0.90

Calls 2

estimate_translation_npFunction · 0.85
toMethod · 0.45

Tested by

no test coverage detected