# Distance between 2 aruco markers

**URL:** <https://forum.opencv.org/t/distance-between-2-aruco-markers/13329>\
**Category:** C++\
**Tags:** aruco\
**Created:** [May 27, 2023, 10:45pm UTC](https://forum.opencv.org/t/distance-between-2-aruco-markers/13329 "2023-05-27T22:45:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wanless](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/wanless/32/7965_2.png) [@wanless](https://forum.opencv.org/u/wanless)\
**Post date:** [May 27, 2023, 10:45pm UTC](https://forum.opencv.org/t/distance-between-2-aruco-markers/13329/1 "2023-05-27T22:45:58Z")

</div>

I have a use case where I want to measure the real-world distance between 2 Aruco markers of a known size. I have tried the below but I’m getting some unusual measurements, it could be to do with poor camera calibration but i just wanted to check if my logic sounded ok.

I am capturing an image then using DetectMarkers to check if 2 and only 2 Aruco markers with the id 1 and 2 are seen. If they are I am running EstimatePoseSingleMarkers. Then using the returned tvec values for the 2 markers I’m doing the below.

sqrt((Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2)));

Where x1 and y1 are the marker 1’s tvec x and y cords and x2 and y2 are marker 2’s tvec x and y cords.

Sorry for the question but just wanted to check im in the right ballpark before i spend more time on improving the odd results.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [May 27, 2023, 11:07pm UTC](https://forum.opencv.org/t/distance-between-2-aruco-markers/13329/2 "2023-05-27T23:07:11Z")

</div>

why no Z?

also, why not simply `cv::norm(tvec1 - tvec2)`?

you also need to make sure aruco gives you the center of a marker. if it gives you a corner of a marker… you’re merely calculating the distance between their respective corners, which the positions of which depend on each marker’s orientation in space.
