YoungXIAO13 / PoseFromShape

(BMVC 2019) PyTorch implementation of Paper "Pose from Shape: Deep Pose Estimation for Arbitrary 3D Objects"
http://imagine.enpc.fr/~xiaoy/PoseFromShape/
MIT License
170 stars 34 forks source link

how to get the rotation matrix according to azimuth, elevation and in plane rotation? #7

Closed LittleYuer closed 5 years ago

LittleYuer commented 5 years ago

Hi Yang,

Thanks for great work.

May i ask how to get the rotation matrix according to azimuth, elevation and in plane rotation angles?

Thanks,

Yuer

YoungXIAO13 commented 5 years ago

Hi Yuer,

The function to generate rotation matrix from euler angles in my project can be found here.

And this function was also used in StarMap (ECCV 2018).

You can find their reply here.

Yang

LittleYuer commented 5 years ago

Thanks for your reply.

Solved.

May i ask what's the reason that 90 and 180 is added to elevation and in plane rotation angle respectively on Pix3D dataset?

https://github.com/YoungXIAO13/PoseFromShape/blob/4813beb8c687163dd6279e6cea7d8e8e9ceb6f19/auxiliary/dataset.py#L484

Thanks.

Yuer

YoungXIAO13 commented 5 years ago

This was used to transform the angle values from (-180, 180) to (0, 360) degrees, which was then used to create classification labels in training and testing.

For azimuth and in-plane rotation: (-180, 180) --> (0, 360) for elevation: (-90, 90) --> (0, 180)

LittleYuer commented 5 years ago

thanks~

LittleYuer commented 5 years ago

Hi Yang,

I checked the StarMap you mentioned, the way they get the Rotation matrix using e(ele) , a(azi), θ(in plane rotation) is R=RZ(θ)RX(e−π/2)RZ(−a), and the way in your code is the standard ZXZ rotation matrix which is R=RZ(θ)RX(e)RZ(a).

May I ask the reason behind it?

Thanks again for help.

Yuer

YoungXIAO13 commented 5 years ago

Hi,

Actually, I've done the same thing.

Since the original elevation e is in (-90, 90), and my elevation prediction e_pred is in (0, 180) as I've done in data loader, so in this line I minused e_pred by 180 to get RX(e−π/2).

As for RZ(−a), the azimuth in my annotations already changed to -a compared to the original a provided in Pascal3D or ObjectNet3D. So I keep it this way, i.e. RZ(a).

Besides, since this metric is error on the spherical manifold of euler angles, it should give the same value whether you apply RZ(a) or RZ(-a)

Yang

LittleYuer commented 5 years ago

Thanks.

Make big sense.

Yuer

LittleYuer commented 5 years ago

Hi Yang,

I think R=RZ(θ)RX(e−π/2)RZ(−a) is the way to get the rotation matrix on PASCAL 3D+, given θ (-pi,pi), e(-pi/2, pi/2), a(-pi,pi).

Is the same way on PIX3D dataset?

Thanks~

Yuer

YoungXIAO13 commented 5 years ago

I think it might be more clear to explain in this way:

For all the datasets used in this project: the default value range for euler angles is: θ (-pi, pi), e(-pi/2, pi/2), a(-pi, pi) and the output value range of my dataloader is: θ (0, 2pi), e(0, pi), a(0, 2pi).

Therefore, in the evaluation code, I minus θ and e by pi to get the right RZ(θ)RX(e−π/2). As for RZ(−a), I think you don't need to worry it as this metric is periodic with period 2pi on azimuth.

In short, it is the same way on Pix3D, no worry~

Yang