gulvarol / bodynet

BodyNet: Volumetric Inference of 3D Human Body Shapes, ECCV 2018
http://www.di.ens.fr/willow/research/bodynet
MIT License
261 stars 42 forks source link

Why the render body image has a little deviation with the origin image? #2

Closed ypflll closed 5 years ago

ypflll commented 6 years ago

I am trying to use SMPL parameter provided by surreal, to get the rendered body image. I use the code in fit_surreal.py

# Set ground truth pose and shape
    pose = info['pose'][:, frameNo]
    pose[0:3] = smpl_utils.rotateBody(RzBody, pose[0:3])
    m.pose[:] = pose
    shape = info['shape']
    m.betas[:] = shape[:, 0]
    smpl_utils.renderBody(m)

Then, I get this result (right is the origin image): image

This sames right. However, when I overlap the two images, I find that they have a little deviation: image

The image is extracted from .mp4 file, with size of 320x240, so I change the resolution in fit_surreal.py from [640,480] to [320,240]. Is there anything wrong in the parameters?

gulvarol commented 6 years ago

The renderBody function was just used for visualization. The camera parameters here are not set with the ones from Surreal.

ypflll commented 6 years ago

All wright. Seems I've misunderstood this. So I turned back to the code in surreal project. I get the the intrinsic and extrinsic matrix with your matlab code(https://github.com/gulvarol/surreal/tree/master/datageneration/misc/3Dto2D). They are fixed for the surreal dataset: Intrinsic matrix is fixed for the surreal dataset: [[600,0,160],[0,600,120],[0,0,1]] When has camera locatiion [6.745622158050537;-0.983883023262024;-1.929298996925354], extrinsic matrix is:[[0,0,-1.,-1.9292990],[0,1.,0,0.98388302],[-1.,0,0,6.7456222]]

Then I use this code:

        theta = info['zrot'][i]#*math.pi/180
    Rot_z = np.array([[math.cos(theta), -math.sin(theta), 0], [math.sin(theta), math.cos(theta), 0], [0, 0, 1]])

    # Set ground truth pose and shape
    pose = info['pose'][:,i]
    pose[0:3] = smpl_utils.rotateBody(Rot_z, pose[0:3])
    m.pose[:] = pose
    m.betas[:] = info['shape'][:,i]

    intrinsic = np.array([[600,0,160],[0,600,120],[0,0,1]])
    extrinsic = np.array([[0,0,-1.,-1.9292990],[0,1.,0,0.98388302],[-1.,0,0,6.7456222]])
    M = np.dot(intrinsic, extrinsic)

    vertices = np.concatenate((m.r, np.ones((m.r.shape[0],1))), axis=1)
    coord_projected = np.dot(M, vertices.T)
    coord_projected[0,:] /= coord_projected[2,:]
    coord_projected[1,:] /= coord_projected[2,:]

    for j in range(m.r.shape[0]):
        cv2.circle(img,(int(coord_projected[0,j]),int(coord_projected[1,j])),1,(0,0,255),-1)

    cv2.imshow('a',img)
    cv2.waitKey(0)

image

Still not right. Most of X values are minus than zero. However the given 3d joints is right when projected to 2d. So I doubt that there's something wrong in the given SMPL parameter. Is this the right way to use it? Or did I still have some misunderstanding about some parameters?

gulvarol commented 5 years ago

Please see my answer to issue #10 at the surreal repository.