Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Converting ArUco axis-angle to Unity3D Quaternion

I'm interested in comparing the quaternions of an object presented in the real-world (with ArUco marker on top of it) and its simulated version in Unity3D.

To do this, I generated different scenes in Unity with the object in different locations. I stored its position and orientation relative to the camera in a csv file. where quaternions is looking something like this (for one example):

[-0.492555320262909 -0.00628990028053522 0.00224017538130283 0.870255589485168]

In ArUco, after using estimatePoseSingleMarkers I got a compact version of Angle-Axis, and I converted it to Quaternion using the following function:

def find_quat(rvecs): a = np.array(rvecs[0][0]) theta = math.sqrt(a[0]**2 + a[1]**2 + a[2]**2) b = a/theta qx = b[0] * math.sin(theta/2) qy = -b[1] * math.sin(theta/2) # left-handed vs right handed qz = b[2] * math.sin(theta/2) qw = math.cos(theta/2) print(qx, qy, qz, qw)

where rvecs is the return value of ArUco

However, after doing this I'm still getting way different results, example of the same scene:

[0.9464098048208864 -0.02661258975275046 -0.009733748408866453 0.321722715311581] << aruco result

[-0.492555320262909 -0.00628990028053522 0.00224017538130283 0.870255589485168] << Unity's result

Am I missing something?

EDIT P.S. I don't understand why would someone downvote a question: 1. if it's super stupid you can just answer it while downvoting 2. if it's missing something you can tell me 3. others: you can still tell me... we're here to help each other

Converting ArUco axis-angle to Unity3D Quaternion

I'm interested in comparing the quaternions of an object presented in the real-world (with ArUco marker on top of it) and its simulated version in Unity3D.

To do this, I generated different scenes in Unity with the object in different locations. I stored its position and orientation relative to the camera in a csv file. where quaternions is looking something like this (for one example):

[-0.492555320262909 -0.00628990028053522 0.00224017538130283 0.870255589485168]

In ArUco, after using estimatePoseSingleMarkers I got a compact version of Angle-Axis, and I converted it to Quaternion using the following function:

def find_quat(rvecs): a = np.array(rvecs[0][0]) theta = math.sqrt(a[0]**2 + a[1]**2 + a[2]**2) b = a/theta qx = b[0] * math.sin(theta/2) qy = -b[1] * math.sin(theta/2) # left-handed vs right handed qz = b[2] * math.sin(theta/2) qw = math.cos(theta/2) print(qx, qy, qz, qw) qw)

where rvecs is the return value of ArUco

However, after doing this I'm still getting way different results, example of the same scene:

[0.9464098048208864 -0.02661258975275046 -0.009733748408866453 0.321722715311581] << aruco result

[-0.492555320262909 -0.00628990028053522 0.00224017538130283 0.870255589485168] << Unity's result

Am I missing something?

EDIT P.S. I don't understand why would someone downvote a question: 1. if it's super stupid you can just answer it while downvoting 2. if it's missing something you can tell me 3. others: you can still tell me... we're here to help each other

Converting ArUco axis-angle to Unity3D Quaternion

I'm interested in comparing the quaternions of an object presented in the real-world (with ArUco marker on top of it) and its simulated version in Unity3D.

To do this, I generated different scenes in Unity with the object in different locations. I stored its position and orientation relative to the camera in a csv file. where quaternions is looking something like this (for one example):

[-0.492555320262909 -0.00628990028053522 0.00224017538130283 0.870255589485168]

In ArUco, after using estimatePoseSingleMarkers I got a compact version of Angle-Axis, and I converted it to Quaternion using the following function:

def find_quat(rvecs): a = np.array(rvecs[0][0]) theta = math.sqrt(a[0]**2 + a[1]**2 + a[2]**2) b = a/theta qx = b[0] * math.sin(theta/2) qy = -b[1] * math.sin(theta/2) # left-handed vs right handed qz = b[2] * math.sin(theta/2) qw = math.cos(theta/2) print(qx, qy, qz, qw)

where rvecs is the return value of ArUco

However, after doing this I'm still getting way different results, example of the same scene:

[0.9464098048208864 -0.02661258975275046 -0.009733748408866453 0.321722715311581] << aruco result

[-0.492555320262909 -0.00628990028053522 0.00224017538130283 0.870255589485168] << Unity's result

Am I missing something?

EDIT P.S. I don't understand why would someone downvote a question: 1. if it's super stupid you can just answer it while downvoting 2. if it's missing something you can tell me 3. others: you can still tell me... we're here to help each other

Converting ArUco axis-angle to Unity3D Quaternion

I'm interested in comparing the quaternions of an object presented in the real-world (with ArUco marker on top of it) and its simulated version in Unity3D.

To do this, I generated different scenes in Unity with the object in different locations. I stored its position and orientation relative to the camera in a csv file. where quaternions is looking something like this (for one example):

[-0.492555320262909 -0.00628990028053522 0.00224017538130283 0.870255589485168]

In ArUco, after using estimatePoseSingleMarkers I got a compact version of Angle-Axis, and I converted it to Quaternion using the following function:

def find_quat(rvecs):
   a = np.array(rvecs[0][0])
   theta = math.sqrt(a[0]**2 + a[1]**2 + a[2]**2) 
   b = a/theta 
   qx = b[0] * math.sin(theta/2)
   qy = -b[1] * math.sin(theta/2) # left-handed vs right handed
   qz = b[2] * math.sin(theta/2)
   qw = math.cos(theta/2)
   print(qx, qy, qz, qw)

qw)

where rvecs is the return value of ArUco

However, after doing this I'm still getting way different results, example of the same scene:

[0.9464098048208864 -0.02661258975275046 -0.009733748408866453 0.321722715311581] << aruco result

[-0.492555320262909 -0.00628990028053522 0.00224017538130283 0.870255589485168] << Unity's result

Am I missing something?