stackoverflow.com/questions/12463487/obtain-rotation-axis-from-rotation-matrix-and-translation-vector-in-opencv

    R : 3x3 rotation matrix
    returns axis, angle

def rotMatrix2AxisAndAngle(R):
    """
    stackoverflow.com/questions/12463487/obtain-rotation-axis-from-rotation-matrix-and-translation-vector-in-opencv

    R : 3x3 rotation matrix
    returns axis, angle

    """
    angle = np.arccos((R[0, 0] + R[1, 1] + R[2, 2] - 1)/ 2)
    axis = np.array([
        # x
        (R[2, 1] - R[1, 2])/ np.sqrt((R[2, 1] - R[1, 2])
                                                ** 2 + (R[0, 2] - R[2, 0])**2 + (R[1, 0] - R[0, 1])**2),
        # y
        (R[0, 2] - R[2, 0])/ np.sqrt((R[2, 1] - R[1, 2])
                                                ** 2 + (R[0, 2] - R[2, 0])**2 + (R[1, 0] - R[0, 1])**2),
        # z
        (R[1, 0] - R[0, 1])/ np.sqrt((R[2, 1] - R[1, 2])**2 + 
                                                (R[0, 2] - R[2, 0])**2 + (R[1, 0] - R[0, 1])**2)])
    return axis, angle