# Finding out the distance

**URL:** <https://community.stereolabs.com/t/finding-out-the-distance/1202>\
**Category:** Uncategorized\
**Created:** [May 27, 2022, 1:16pm UTC](https://community.stereolabs.com/t/finding-out-the-distance/1202 "2022-05-27T13:16:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![joeurban](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/j/c4cdca/32.png) [@joeurban](https://community.stereolabs.com/u/joeurban)\
**Post date:** [May 27, 2022, 1:16pm UTC](https://community.stereolabs.com/t/finding-out-the-distance/1202/1 "2022-05-27T13:16:57Z")

</div>

how can I get the  
distance (meter)  
position(x,y,z)  
and velocity(k/m )  
for every object in terminal printed when I run the detector for yolov5 ?[https://github.com/stereolabs/zed-examples/blob/master/object%20detection/custom%20detector/python/pytorch\_yolov5/detector.py](https://github.com/stereolabs/zed-examples/blob/master/object%20detection/custom%20detector/python/pytorch_yolov5/detector.py)

what I made I tried to print the distance for all the object detected already in the scene  
I could find out and print in terminal all the information about all the object expect the distance

 ![Screenshot from 2022-05-27 20-55-33](https://community.stereolabs.com/uploads/default/original/1X/67e7eb1cb7f819fdc34b23b287216c8f1f44cd16.png)  
as you can see here  
I just got the distacne for one point?

how can I get the distance for all the object!

another thing is that why is it slow why I run yolov5 detector???

please help?

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [May 27, 2022, 1:41pm UTC](https://community.stereolabs.com/t/finding-out-the-distance/1202/2 "2022-05-27T13:41:09Z")

</div>

HI @joeurban  
you can find the information in the `object` variable:  
[https://www.stereolabs.com/docs/api/python/classpyzed\_1\_1sl\_1\_1ObjectData.html](https://www.stereolabs.com/docs/api/python/classpyzed_1_1sl_1_1ObjectData.html)

The `distance` that you are calculating with the Euclidean Distance formula there is the distance of the central point of the image

---

<div class="post-metadata">

**Author:** ![joeurban](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/j/c4cdca/32.png) [@joeurban](https://community.stereolabs.com/u/joeurban)\
**Post date:** [May 28, 2022, 11:31am UTC](https://community.stereolabs.com/t/finding-out-the-distance/1202/6 "2022-05-28T11:31:08Z")

</div>

I got it  
Thanks a lot

---

<div class="post-metadata">

**Author:** ![joeurban](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/j/c4cdca/32.png) [@joeurban](https://community.stereolabs.com/u/joeurban)\
**Post date:** [May 28, 2022, 4:48pm UTC](https://community.stereolabs.com/t/finding-out-the-distance/1202/7 "2022-05-28T16:48:30Z")

</div>

Why is it slow? Yolov5 detector is slow ?

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [June 1, 2022, 8:44am UTC](https://community.stereolabs.com/t/finding-out-the-distance/1202/8 "2022-06-01T08:44:00Z")

</div>

YoloV5 is faster if compiled with CUDA and optimized for the GPU that you are using

---

<div class="post-metadata">

**Author:** ![joeurban](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/j/c4cdca/32.png) [@joeurban](https://community.stereolabs.com/u/joeurban)\
**Post date:** [June 1, 2022, 9:12am UTC](https://community.stereolabs.com/t/finding-out-the-distance/1202/9 "2022-06-01T09:12:43Z")

</div>

i am on xavier nx with 20 W and 6 cores  
i have built a conda environment with python 3.8, torch 1.7.0a0,t orchvision 0.8.0a0+291f7e2 and pyzed 3.7!

but the performance is still same!!!  
I am sending the output format via UDP. enve with stopping UPD protocol the performance is still having lag of almost 2 seconds

 ![Screenshot from 2022-06-01 17-11-09](https://community.stereolabs.com/uploads/default/original/1X/0ce660a9d393ff338f671e1cbe36d5233418c399.png)
