nghorbani / human_body_prior

VPoser: Variational Human Pose Prior
https://smpl-x.is.tue.mpg.de/
Other
796 stars 141 forks source link

Getting joint position from body model #28

Open HelloEgg opened 4 years ago

HelloEgg commented 4 years ago

Hi.

I am trying to extract joint positions from body model. I drew the mesh image and it looked fine. However, getting Jtr return values did not return correct result.

The code that I used is as follows :

`def render_smpl_params(bm, pose_body, pose_hand = None, trans=None, betas=None, root_orient=None): ''' :param bm: pytorch body model with batch_size 1 :param pose_body: Nx21x3 :param trans: Nx3 :param betas: Nxnum_betas :return: N x 400 x 400 x 3 '''

from human_body_prior.tools.omni_tools import copy2cpu as c2c
from human_body_prior.tools.omni_tools import colors
from human_body_prior.mesh.mesh_viewer import MeshViewer
faces = c2c(bm.f)

imw, imh = 400, 400

mv = MeshViewer(width=imw, height=imh, use_offscreen=True)

images = []
for fIdx in range(0, len(pose_body)):

    bm.pose_body.data[0,:] = bm.pose_body.new(pose_body[fIdx].reshape(1,-1))
    if pose_hand is not None: bm.pose_hand.data[0,:] = pose_hand
    if trans is not None: bm.trans.data[0,:] = bm.trans.new(trans[fIdx])
    if betas is not None: bm.betas.data[0,:len(betas[fIdx])] = bm.betas.new(betas[fIdx])
    if root_orient is not None: bm.root_orient.data[0,:] = bm.root_orient.new(root_orient[fIdx])

    v = c2c(bm.forward().v)[0]
    jtr = c2c(bm.forward().Jtr)[0]
    mesh = trimesh.base.Trimesh(v, faces, vertex_colors=np.ones_like(v)*colors['grey'])
    mv.set_meshes([mesh], 'static')

    images.append(mv.render())

return np.array(images).reshape(len(pose_body), imw, imh, 3)`

I used jtr frombm.forward().Jtr to extract key point. The mesh I got is as follows

스크린샷, 2020-09-11 22-05-50

And when I plotted joint position from jtr value, I got this

스크린샷, 2020-09-11 22-06-50

Where do you think did I got wrong..? How can I directly extract joint positions from body model? I mean, the shoulder looks too large, the legs aren't supposed to be leaning backwards...

nghorbani commented 3 years ago

You are getting the 3D joints correct. however, looks like there is a a plotting issue. the shoulders look widened because the image is sheered and the aspect ratio is not kept. try playing with a custom 2d joint plotter. leave your code snippet here if you needed help

artpli commented 2 months ago

@nghorbani Hi Nima~

Thanks for sharing the codebase first!!

I encountered a similar issue today: I wanted to retarget a pose from SMPLH to a humanoid robot. Figure 1 shows the result after rendering the data with this human_body_prior. I used the joint information from jtr mentioned above as the joint radians of the robot simulation, resulting in Figure 2. However, I noticed that there are still some differences in the poses between Figure 2 and Figure 1, such as the different elbow angles.

I’ve spent a lot of time trying to address this issue. Could you please help me with it? I would really appreciate it!

Figure 1: img_v3_02dt_580ec30c-06df-495b-a3e6-e0396efac61g

Figure 2: img_v3_02du_0832763c-dfb5-4bef-acbf-a602a53b2eag

youknowwhom commented 2 months ago

used the joint information from jtr mentioned above as the joint radians

Hi, I'm also trying to retarget SMPL to humanoid. Could you please explain how to use "the joint information from jtr mentioned above as the joint radians"? I guess that jtr is the global position of each joint? Thanks a lot.