Nicholasli1995 / EvoSkeleton

Official project website for the CVPR 2020 paper (Oral Presentation) "Cascaded deep monocular 3D human pose estimation wth evolutionary training data"
https://arxiv.org/abs/2006.07778
MIT License
332 stars 44 forks source link

2d poses from 3d pose #61

Closed alsehaimaa closed 3 years ago

alsehaimaa commented 3 years ago

hi how can I extract 2d poses from the resulted 3d pose (2d pose front view, back view, and side view) thanks

Nicholasli1995 commented 3 years ago

hi how can I extract 2d poses from the resulted 3d pose (2d pose front view, back view, and side view) thanks

You can project the 3D pose to 2D with your camera parameters. Use different extrinsic rotation/translation for different views. Method in this repo that can be used is: https://github.com/Nicholasli1995/EvoSkeleton/blob/b2b355f4c1fa842709f100d931189ce80008f6ef/libs/dataset/h36m/cameras.py#L8

alsehaimaa commented 3 years ago

thanks for your replay, i am trying to do it for my own images where i do not have such information is there any default value for it. Thanks in advance

Nicholasli1995 commented 3 years ago

thanks for your replay, i am trying to do it for my own images where i do not have such information is there any default value for it. Thanks in advance

You do not need many parameters to simulate a pin-hole camera. Assume you have 3d pose [x, y, z] in the camera coordinate system (this repo contains it) and you can project it to the screen as [fx/z, fy/z] where f is your focal length. I would suggest you take a look at camera models. See https://docs.opencv.org/4.5.3/d9/d0c/group__calib3d.html for example.

alsehaimaa commented 3 years ago

Thanks for your replay I am trying to use it for my own images i generate the pose using h36mpose.py and then run the inference but can i ask how to generate the stats.npy file ?

Nicholasli1995 commented 3 years ago

Thanks for your replay I am trying to use it for my own images i generate the pose using h36mpose.py and then run the inference but can i ask how to generate the stats.npy file ?

Use this inference script [https://github.com/Nicholasli1995/EvoSkeleton/blob/master/examples/inference.py](). Download the file following the instruction here [https://github.com/Nicholasli1995/EvoSkeleton/blob/master/docs/TRAINING.md]().

alsehaimaa commented 3 years ago

thanks so much for your replay I follow the instructions I just have trouble showing the 2d projection from 3d pose as follows index1

: index index5 index4 index3

How can I visualize it right so I can see how accurate the projected 2d poses?

Thanks for everything, the code and support.

alsehaimaa commented 3 years ago

i try to use the following code but yet did not get it

`def project_to_cameras(poses): """ Project 3d poses using camera parameters input: 3D poses: [n_pose, pose length] cams: list of camera parameters return: list of 2D projections for each camera cams: """ p_2d = [] rcams= np.load('/Pose_for_Re-id/EvoSkeleton_master/cameras.npy', allow_pickle=True).item()

print('befor adding')

cams = add_virtual_cams(rcams)
#print('after adding')
# By default, all actions are used
ncams=4
for cam in range(ncams):
    R, T, f, c, k, p, name = cams[(1, cam+1)]

    pts2d, _, _, _, _ = cameras.project_point_radial(np.reshape(poses, [-1, 3]), R, T, f, c, k, p )

    f = plt.figure(figsize=(9, 9))
    ax4 = plt.subplot(131)
    plt.title('2D key-point inputs: {:d}*2'.format(16))
    ax4.set_aspect('equal')
    ax4.invert_yaxis()
    skeleton_pred = None

    s2d=pts2d
    show2Dpose(np.reshape( pts2d, [-1, len(H36M_NAMES)*2]),ax4)
    p_2d.append(np.reshape( pts2d, [-1, len(H36M_NAMES)*2]))

return p_2d`

the results was index15 index13 index12 index11 :

alsehaimaa commented 3 years ago

If I need to rotate around the y-axis what should I change?

Nicholasli1995 commented 3 years ago

If I need to rotate around the y-axis what should I change?

See ax.set_xlim/set_ylim to control your 2D plot. Change R and T to the camera pose that you need.

alsehaimaa commented 3 years ago

Thanks but wen i change the anagle in add_virtual_cams to: new_R, new_T = get_new_camera(R.T, T, [0.,angle, 0.]) nothing changed.

Nicholasli1995 commented 3 years ago

Thanks but wen i change the anagle in add_virtual_cams to: new_R, new_T = get_new_camera(R.T, T, [0.,angle, 0.]) nothing changed.

You do not understand the code and coordinate transformation and I don't have time for beginner tutorial. Why not you upload your 3D pose and I simply write you a script to run? You can create a page in the discussion and I'm closing this issue since it's not a bug.