ArUco Orientation Estimation

I am trying to estimate camera orientation with respect to an ArUco marker map. I convert the rvec into rotation matrix and then convert it to Euler angles using the code from the following website: https://www.learnopencv.com/rotation-matrix-to-euler-angles/

Then, I use a well-calibrated IMU as a ground truth value. There are 3 different marker dictionaries used: 4x4 markers, 5x5 markers, and 6x6 markers. However, I have a different result even though all are located on the same position (results shown below). Moreover, the result is not exactly the same as the IMU. How can I improve the orientation estimation?

Picture1