OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Sun, 05 Apr 2020 15:54:59 -0500ArUco: Getting the coordinates of a marker in the coordinate system of another markerhttp://answers.opencv.org/question/228502/aruco-getting-the-coordinates-of-a-marker-in-the-coordinate-system-of-another-marker/Hi,
I have a question regarding pose estimation of ArUco markers and coordinate system translation. What I would basically like to accomplish is to get the coordinates of a marker using a coordinate system that is based on another marker.
Let me explain. The plan is to use one stationary marker as a calibration point. After getting the rvec and tvec vectors of that calibration marker I would then like to use this information to calculate the coordinates of the others, in the calibration marker’s coordinate system. (note that the camera and calibration tag are stationary, while the others move)
![image description](/upfiles/1586018710893619.png)
The end goal is to get the x and y coordinates of the markers in mm on the plane of interest. I could then move the origin point, to suite my application, with some simple addition/subtraction as the absolute position of my calibration marker is known.
![image description](/upfiles/15860178122705141.png)
I’ve already figured out how to get the coordinates of markers in the camera’s coordinate system and how to get the camera’s coordinates in the coordinate system of a marker, but I haven’t been able to understand **how can I get the coordinates of a marker, in the coordinate system of another marker.**
I’m not really familiar with all of these computer vision concepts, so I have been reading things that have been previously suggested (like [this](https://docs.opencv.org/4.2.0/d9/d0c/group__calib3d.html#details), and [this](https://docs.opencv.org/4.2.0/d9/d0c/group__calib3d.html#ga549c2075fac14829ff4a58bc931c033d)), but I haven’t been able to find a solution yet.
I would really appreciate if you could verify that what I’m trying to do is possible and to point me in the right direction.
ThanksSat, 04 Apr 2020 11:38:14 -0500http://answers.opencv.org/question/228502/aruco-getting-the-coordinates-of-a-marker-in-the-coordinate-system-of-another-marker/Comment by balourdos for <p>Hi,</p>
<p>I have a question regarding pose estimation of ArUco markers and coordinate system translation. What I would basically like to accomplish is to get the coordinates of a marker using a coordinate system that is based on another marker. </p>
<p>Let me explain. The plan is to use one stationary marker as a calibration point. After getting the rvec and tvec vectors of that calibration marker I would then like to use this information to calculate the coordinates of the others, in the calibration marker’s coordinate system. (note that the camera and calibration tag are stationary, while the others move)</p>
<p><img alt="image description" src="/upfiles/1586018710893619.png"></p>
<p>The end goal is to get the x and y coordinates of the markers in mm on the plane of interest. I could then move the origin point, to suite my application, with some simple addition/subtraction as the absolute position of my calibration marker is known.</p>
<p><img alt="image description" src="/upfiles/15860178122705141.png"></p>
<p>I’ve already figured out how to get the coordinates of markers in the camera’s coordinate system and how to get the camera’s coordinates in the coordinate system of a marker, but I haven’t been able to understand <strong>how can I get the coordinates of a marker, in the coordinate system of another marker.</strong></p>
<p>I’m not really familiar with all of these computer vision concepts, so I have been reading things that have been previously suggested (like <a href="https://docs.opencv.org/4.2.0/d9/d0c/group__calib3d.html#details">this</a>, and <a href="https://docs.opencv.org/4.2.0/d9/d0c/group__calib3d.html#ga549c2075fac14829ff4a58bc931c033d">this</a>), but I haven’t been able to find a solution yet. </p>
<p>I would really appreciate if you could verify that what I’m trying to do is possible and to point me in the right direction.</p>
<p>Thanks</p>
http://answers.opencv.org/question/228502/aruco-getting-the-coordinates-of-a-marker-in-the-coordinate-system-of-another-marker/?comment=228561#post-id-228561I tried what I was suggesting but it unfortunately didn't work. Is anyone able to see what I did wrong?Sun, 05 Apr 2020 15:54:59 -0500http://answers.opencv.org/question/228502/aruco-getting-the-coordinates-of-a-marker-in-the-coordinate-system-of-another-marker/?comment=228561#post-id-228561Comment by balourdos for <p>Hi,</p>
<p>I have a question regarding pose estimation of ArUco markers and coordinate system translation. What I would basically like to accomplish is to get the coordinates of a marker using a coordinate system that is based on another marker. </p>
<p>Let me explain. The plan is to use one stationary marker as a calibration point. After getting the rvec and tvec vectors of that calibration marker I would then like to use this information to calculate the coordinates of the others, in the calibration marker’s coordinate system. (note that the camera and calibration tag are stationary, while the others move)</p>
<p><img alt="image description" src="/upfiles/1586018710893619.png"></p>
<p>The end goal is to get the x and y coordinates of the markers in mm on the plane of interest. I could then move the origin point, to suite my application, with some simple addition/subtraction as the absolute position of my calibration marker is known.</p>
<p><img alt="image description" src="/upfiles/15860178122705141.png"></p>
<p>I’ve already figured out how to get the coordinates of markers in the camera’s coordinate system and how to get the camera’s coordinates in the coordinate system of a marker, but I haven’t been able to understand <strong>how can I get the coordinates of a marker, in the coordinate system of another marker.</strong></p>
<p>I’m not really familiar with all of these computer vision concepts, so I have been reading things that have been previously suggested (like <a href="https://docs.opencv.org/4.2.0/d9/d0c/group__calib3d.html#details">this</a>, and <a href="https://docs.opencv.org/4.2.0/d9/d0c/group__calib3d.html#ga549c2075fac14829ff4a58bc931c033d">this</a>), but I haven’t been able to find a solution yet. </p>
<p>I would really appreciate if you could verify that what I’m trying to do is possible and to point me in the right direction.</p>
<p>Thanks</p>
http://answers.opencv.org/question/228502/aruco-getting-the-coordinates-of-a-marker-in-the-coordinate-system-of-another-marker/?comment=228514#post-id-228514Thank you for the response. I think I have something, please correct me if I’m wrong.
So, I can firstly take the tvec and rvec of my calibration tag and create the 4x4 matrix you were talking about, which consists of rordigues(rvec), tvec, padded with 0 0 0 1 at the last line.
This gives me a change of basis matrix from the camera coordinate system to the calib_tag one, which I’ll name M_calib.
I do the same for one of the other markers (tag#2 for example) and I get M2 and its inverse. I then multiply the coordinates of the tag#2 (tvec of tag#2) with the matrices that I got:
M^-1_2 * M_calib * (x y z 1) = (x' y' z' 1)
And at the end I should get the coordinates of the tag#2, expressed in the coordinate system of the calibration tag.Sat, 04 Apr 2020 17:34:32 -0500http://answers.opencv.org/question/228502/aruco-getting-the-coordinates-of-a-marker-in-the-coordinate-system-of-another-marker/?comment=228514#post-id-228514Comment by crackwitz for <p>Hi,</p>
<p>I have a question regarding pose estimation of ArUco markers and coordinate system translation. What I would basically like to accomplish is to get the coordinates of a marker using a coordinate system that is based on another marker. </p>
<p>Let me explain. The plan is to use one stationary marker as a calibration point. After getting the rvec and tvec vectors of that calibration marker I would then like to use this information to calculate the coordinates of the others, in the calibration marker’s coordinate system. (note that the camera and calibration tag are stationary, while the others move)</p>
<p><img alt="image description" src="/upfiles/1586018710893619.png"></p>
<p>The end goal is to get the x and y coordinates of the markers in mm on the plane of interest. I could then move the origin point, to suite my application, with some simple addition/subtraction as the absolute position of my calibration marker is known.</p>
<p><img alt="image description" src="/upfiles/15860178122705141.png"></p>
<p>I’ve already figured out how to get the coordinates of markers in the camera’s coordinate system and how to get the camera’s coordinates in the coordinate system of a marker, but I haven’t been able to understand <strong>how can I get the coordinates of a marker, in the coordinate system of another marker.</strong></p>
<p>I’m not really familiar with all of these computer vision concepts, so I have been reading things that have been previously suggested (like <a href="https://docs.opencv.org/4.2.0/d9/d0c/group__calib3d.html#details">this</a>, and <a href="https://docs.opencv.org/4.2.0/d9/d0c/group__calib3d.html#ga549c2075fac14829ff4a58bc931c033d">this</a>), but I haven’t been able to find a solution yet. </p>
<p>I would really appreciate if you could verify that what I’m trying to do is possible and to point me in the right direction.</p>
<p>Thanks</p>
http://answers.opencv.org/question/228502/aruco-getting-the-coordinates-of-a-marker-in-the-coordinate-system-of-another-marker/?comment=228504#post-id-228504you need to turn your rvec and tvec info into good old 4x4 matrices that express this transformation. the rest is "easy".
read up on some computer **graphics** concepts such as transformation matrices, projective spaces, homogeneous coordinates. they're 4-element vectors and 4x4 matrices. the basics are: divide a vector by 4th component to get it back into "normal" space. multiply matrices to get a complex transformation. the identity matrix is the basis for lots of things. look at a matrix that translates, one that scales, one that rotates.Sat, 04 Apr 2020 13:19:17 -0500http://answers.opencv.org/question/228502/aruco-getting-the-coordinates-of-a-marker-in-the-coordinate-system-of-another-marker/?comment=228504#post-id-228504Comment by crackwitz for <p>Hi,</p>
<p>I have a question regarding pose estimation of ArUco markers and coordinate system translation. What I would basically like to accomplish is to get the coordinates of a marker using a coordinate system that is based on another marker. </p>
<p>Let me explain. The plan is to use one stationary marker as a calibration point. After getting the rvec and tvec vectors of that calibration marker I would then like to use this information to calculate the coordinates of the others, in the calibration marker’s coordinate system. (note that the camera and calibration tag are stationary, while the others move)</p>
<p><img alt="image description" src="/upfiles/1586018710893619.png"></p>
<p>The end goal is to get the x and y coordinates of the markers in mm on the plane of interest. I could then move the origin point, to suite my application, with some simple addition/subtraction as the absolute position of my calibration marker is known.</p>
<p><img alt="image description" src="/upfiles/15860178122705141.png"></p>
<p>I’ve already figured out how to get the coordinates of markers in the camera’s coordinate system and how to get the camera’s coordinates in the coordinate system of a marker, but I haven’t been able to understand <strong>how can I get the coordinates of a marker, in the coordinate system of another marker.</strong></p>
<p>I’m not really familiar with all of these computer vision concepts, so I have been reading things that have been previously suggested (like <a href="https://docs.opencv.org/4.2.0/d9/d0c/group__calib3d.html#details">this</a>, and <a href="https://docs.opencv.org/4.2.0/d9/d0c/group__calib3d.html#ga549c2075fac14829ff4a58bc931c033d">this</a>), but I haven’t been able to find a solution yet. </p>
<p>I would really appreciate if you could verify that what I’m trying to do is possible and to point me in the right direction.</p>
<p>Thanks</p>
http://answers.opencv.org/question/228502/aruco-getting-the-coordinates-of-a-marker-in-the-coordinate-system-of-another-marker/?comment=228505#post-id-228505if you have matrices expressing marker-space-to-camera-space transformations, let's say M1 and M2, the transformation from marker 1 space to marker 2 space is M2^-1 * M1. point in M1 space is transformed into camera space ("forward" M1 transformation), then transformed into M2 space (inverted M2 transformation). what you have now can tell you for any point in M1 space, where in M2 space it is. apply this to (0,0,0) to get M1's origin in M2 space. you can apply it to basis vectors too.Sat, 04 Apr 2020 13:24:24 -0500http://answers.opencv.org/question/228502/aruco-getting-the-coordinates-of-a-marker-in-the-coordinate-system-of-another-marker/?comment=228505#post-id-228505