nghorbani/human_body_prior

Getting joint position from body model

HelloEgg opened this issue · 3 comments

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 from bm.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...

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