Simplest way to visualize HMR or SPIN or Smplify pred smpl with origin frames and predicted cameras.
(cam_transl,
bbox=None,
kp2d=None,
focal_length=5000,
det_width=224,
det_height=224,
bbox_format='xyxy',
**kwargs)
| 1077 | |
| 1078 | |
| 1079 | def visualize_smpl_hmr(cam_transl, |
| 1080 | bbox=None, |
| 1081 | kp2d=None, |
| 1082 | focal_length=5000, |
| 1083 | det_width=224, |
| 1084 | det_height=224, |
| 1085 | bbox_format='xyxy', |
| 1086 | **kwargs) -> None: |
| 1087 | """Simplest way to visualize HMR or SPIN or Smplify pred smpl with origin |
| 1088 | frames and predicted cameras.""" |
| 1089 | if kp2d is not None: |
| 1090 | bbox = convert_kp2d_to_bbox(kp2d, bbox_format=bbox_format) |
| 1091 | Ks = convert_bbox_to_intrinsic(bbox, bbox_format=bbox_format) |
| 1092 | K = torch.Tensor( |
| 1093 | get_default_hmr_intrinsic(focal_length=focal_length, |
| 1094 | det_height=det_height, |
| 1095 | det_width=det_width)) |
| 1096 | func = partial( |
| 1097 | render_smpl, |
| 1098 | projection='perspective', |
| 1099 | convention='opencv', |
| 1100 | in_ndc=False, |
| 1101 | K=None, |
| 1102 | R=None, |
| 1103 | orig_cam=None, |
| 1104 | ) |
| 1105 | if isinstance(cam_transl, np.ndarray): |
| 1106 | cam_transl = torch.Tensor(cam_transl) |
| 1107 | T = torch.cat([ |
| 1108 | cam_transl[..., [1]], cam_transl[..., [2]], 2 * focal_length / |
| 1109 | (det_width * cam_transl[..., [0]] + 1e-9) |
| 1110 | ], -1) |
| 1111 | for k in func.keywords.keys(): |
| 1112 | if k in kwargs: |
| 1113 | kwargs.pop(k) |
| 1114 | return func(Ks=Ks, K=K, T=T, **kwargs) |
| 1115 | |
| 1116 | |
| 1117 | def visualize_smpl_vibe(orig_cam=None, |
nothing calls this directly
no test coverage detected