ArUcoDetectionHoloLens-Unity icon indicating copy to clipboard operation
ArUcoDetectionHoloLens-Unity copied to clipboard

question about this function CvUtils.RotationQuatFromRodrigues()

Open ANG0-0GNA opened this issue 3 years ago • 0 comments

Hi, Mitchell,

Thanks for your great work! I'm reading your code and have a problem about the transformation between the frame 'unity' and 'marker' in the script ArUcoMarkerDetection.cs. // Get pose from OpenCV and format for Unity
Vector3 position = CvUtils.Vec3FromFloat3(detectedMarker.Position);
position.y *= -1f;
Quaternion rotation = CvUtils.RotationQuatFromRodrigues(CvUtils.Vec3FromFloat3(detectedMarker.Rotation));
Matrix4x4 cameraToWorldUnity = CvUtils.Mat4x4FromFloat4x4(detectedMarker.CameraToWorldUnity);
Matrix4x4 transformUnityCamera = CvUtils.TransformInUnitySpace(position, rotation);
// Use camera to world transform to get world pose of marker
Matrix4x4 transformUnityWorld = cameraToWorldUnity * transformUnityCamera; In this function CvUtils.RotationQuatFromRodrigues(CvUtils.Vec3FromFloat3(detectedMarker.Rotation)), we input the rotation detectedMarker.Rotation which is between 'opencv' and 'aruco'. The output is the rotation between unity and aruco. But I don't know why we need to multiply Quaternion.Euler(0, 0, 180) in this function CvUtils.RotationQuatFromRodrigues(). Because the euler angle between 'unity' and 'opencv' is q = Quaternion.Euler( -1.0f * q.eulerAngles.x, q.eulerAngles.y, -1.0f * q.eulerAngles.z). q = Quaternion.Euler( -1.0f * q.eulerAngles.x, q.eulerAngles.y, -1.0f * q.eulerAngles.z) * Quaternion.Euler(0, 0, 180);

Would you give me some suggestions? Thanks!

Best regards, Ang

ANG0-0GNA avatar Apr 25 '21 10:04 ANG0-0GNA