DLR-RM / AugmentedAutoencoder

Official Code: Implicit 3D Orientation Learning for 6D Object Detection from RGB Images
MIT License
336 stars 97 forks source link

Rotation matrix results #85

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello, sorry for bothering again, but I find your work very useful.

I have the following output from inference

out

and I converted the 3d Rotation Matrixes into euler angels (in range 0-360 degrees) using the following code:

`

 def rotationMatrixToEulerAngles(self,R):
    sy = np.sqrt(R[0,0] * R[0,0] +  R[1,0] * R[1,0])
    singular = sy < 1e-6
    if  not singular :
        x = math.atan2(R[2,1] , R[2,2])
        y = math.atan2(-R[2,0], sy)
        z = math.atan2(R[1,0], R[0,0])
    else :
        x = math.atan2(-R[1,2], R[1,1])
        y = math.atan2(-R[2,0], sy)
        z = 0
    return np.array([((x * 180 / np.pi) + 360) % 360, ((y * 180 / np.pi) + 360) % 360, ((z * 180 / np.pi) + 360) % 360 ])

`

and I get the following euler angles (from left object to right) [326.86821165 61.95437172 326.2957167 ] [272.9466035 319.63736395 270.66490116] [255.16130013 321.15237189 282.06110633]

It makes sense that for one of the axis the angle could be anything (the one from which the rendered view aspect is irrelevant), but for the other two I was expecting more similar results, even because the output image seems to show a little offset between each object orientation. Is it wrong how I convert to euler angles from your 3d Matrix or is it something else? Again, thank you ;)

MartinSmeyer commented 3 years ago

I wouldn't recommend converting to Euler angles at all. Why do you need it?

ghost commented 3 years ago

Some tests I'm doing with a robotic arm which needs euler angles for the picking.

MartinSmeyer commented 3 years ago

Sorry I wont debug your code. There can be ambiguous solutions when converting from matrix to euler. Here is a conversion if you follow a set of conventions:

https://github.com/thodan/bop_toolkit/blob/53150b649467976b4f619fbffb9efe525c7e11ca/bop_toolkit_lib/transform.py#L1112