Hi there!

I'm creating a university project with OpenCV Python and ArUco markers, where I would like to get a (relatively) robust pose estimation for the movement of the camera. I plan on using this for indoor drone flight graphing.

My idea is that the first seen marker will be the origin of my coordinate system. I store the origin of each marker (the first seen position transformed into the first markers coordinate system) and estimate a camera pose from that. My problem is, that I cannot seem to solve the transformation between the two markers' points.

I was able to get a camera position corrected for the marker rotation with the rotation matrix got from `rvecs`

. I've been trying out almost all combinations of signs and matrices, after the theory did not work. Now I feel a little bit lost and am looking for some help with the transformations.

first aruco marker:

`tvec_1`

,`rvec_1`

-->`R1`

(rotation matrix)second aruco marker:

`tvec_2`

,`rvec_2`

-->`R2`

(rotation matrix)

To get the camera coordinates in the marker's coordinate system: `tvec_m = np.matmul(tvec, -R)`

I get two vectors like this (`tvec_m1`

and `tvec_m2`

), both interpreted in their respective marker's Cartesian coordinates. (Just as the `aruco.drawAxis`

function shows them.) These work pretty well, I can graph the camera position and get good values.

The mathematical transformation from the second to the first marker:

p1 and p2 vectors, M1 and M2 are the respective coordinate system rotation matrices, O1 and O2 are the origins of coordinate systems

`O1 + M1 p1 = O2 + M2 p2`

and so`p1 = transpose[M1] (O2 - O1 + M2 p2)`

In code it looks like this: (the matrix multiplication is reversed, because `tvec`

is row vector instead of column)

```
d_origins = tvec_2 - tvec_1
tvec_m1 = np.matmul(tvec_1, -R1)
tvec_m2 = np.matmul(tvec_2, -R2)
tvec_m21 = np.matmul(d_origins + tvec_m2, R1.T)
```

Like this, I should be able to get `tvec_m21 == tvec_m1`

(of course not exactly, but approximately the same vector), but until yet, no luck.

Is this even a possible way for coordinate transformation between markers? I'm afraid, I keep falling for the same mistake and I won't notice it anymore. What am I doing wrong?

Thanks in advance!