I have used yolov5
for object detection and trained it on my own dataset, now it can detect my two objects. I want to calculate the distance between these two objects. how can I do that?
the command that runs the yolov5
and detects my objects is as below:
python detect.py --weights runs\train\exp2\weights\last.pt --img 640 --conf 0.25 --source 0
Try calculating ditances on this flat image where you don't have any valid reference.
Are this people equally tall? Are they equally far from the camera? Are windows really this shape?
You cannot. You simply cannot. You don't have depth information, you don't have any ofject you can take as a reference to calculate images. You cannot calculate distances on flat images without more information.
In a flat 2D image you cannot calculate distances, unless you take assumptions (like the size of the windows) which might be completely wrong, like in this image.