bharat-b7 / MultiGarmentNetwork

Repo for "Multi-Garment Net: Learning to Dress 3D People from Images, ICCV'19"
282 stars 65 forks source link

Code to convert the 9 numbers in `m['pose_N'][0,1]` to `(72,)==smpl.pose.shape`? #39

Open neonb88 opened 4 years ago

neonb88 commented 4 years ago

Hi @bharat-b7 ,

I'm sure you are quite busy, but 10 minutes of your time could potentially save me hours. Is there code to convert the (3,3) numbers in m['pose_N'][0,1] to the 3 ((3,)) angles per joint (72 pose parameters) used by SMPL?

https://github.com/bharat-b7/MultiGarmentNetwork/issues/24#issuecomment-632296220

Thanks, Nathan

bharat-b7 commented 4 years ago

Hi, you can use the following to convert rotation matrix to vector. https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.html

I haven't tested but a combination of 'from_matrix()' and 'as_rotvec()' should do the job.

neonb88 commented 4 years ago

@bharat-b7 Thanks! Will check it out. But does it deal with the issue of "dependent rotations" ? ie. I mean where global rotation of the wrist depends on local rotation of all joints "above" the wrist on the kinematic tree (ie. elbow, shoulder)?

neonb88 commented 4 years ago

@bharat-b7 Thanks! Will check it out. But does it deal with the issue of "dependent rotations" ? ie. I mean where global rotation of the wrist depends on local rotation of all joints "above" the wrist on the kinematic tree (ie. elbow, shoulder)?

At least, this is an issue unless someone pre-defined the order of the rotations from out['pose_0'][0] to always be the same (ie. global rotates before back rotates before shoulder b4 elbow b4 wrist)

hshreeshail commented 2 years ago

Hi, you can use the following to convert rotation matrix to vector. https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.html

I haven't tested but a combination of 'from_matrix()' and 'as_rotvec()' should do the job.

Hi @neonb88, I am facing the same issue. Did this answer work for you? If not, could you please share what worked. Thanks in advance.

hshreeshail commented 2 years ago

Using the following worked for me

from scipy.spatial.transform import Rotation as R
r = R.from_matrix(rot_matrix).as_rotvec()