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

Function estimate_cam_weakperspective_batch

detrsmpl/utils/geometry.py:496–528  ·  view source on GitHub ↗

img_size: b,w,h

(
        joints3d, joints2d, 
        joints2d_conf, joints3d_conf,
        img_size)

Source from the content-addressed store, hash-verified

494 return cam
495
496def estimate_cam_weakperspective_batch(
497 joints3d, joints2d,
498 joints2d_conf, joints3d_conf,
499 img_size):
500 '''
501 img_size: b,w,h
502 '''
503 device = joints3d.device
504 joints2d = joints2d.detach().cpu()
505 joints3d = joints3d.detach().cpu()
506
507 assert joints2d.ndim == 3 # B, J, 2
508 assert joints3d.ndim == 3 # B, J, 3
509
510 cam = torch.zeros(joints3d.shape[0], 3)
511 for i in range(joints3d.shape[0]):
512 joints3d_i = joints3d[i]
513 joints2d_i = joints2d[i]
514 if joints2d_conf is not None:
515 conf2d_i = joints2d_conf[i].detach().cpu()
516 else:
517 conf2d_i = None
518
519 if joints3d_conf is not None:
520 conf3d_i = joints3d_conf[i].detach().cpu()
521 else:
522 conf3d_i = None
523 cam[i] = estimate_cam_weakperspective(joints3d=joints3d_i,
524 joints2d=joints2d_i,
525 joints2d_conf=conf2d_i,
526 joints3d_conf=conf3d_i,
527 img_size=img_size[i])
528 return cam.to(device)
529
530def pred_cam_to_transl(pred_camera, focal_length, img_size):
531 pred_cam_t = torch.stack([

Callers

nothing calls this directly

Calls 3

detachMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected