paul-pias / Object-Detection-and-Distance-Measurement

Using yolov3 & yolov4 weights objects are being detected from live video frame along with the measurement of the object from the camera without the support of any extra hardware device.
348 stars 118 forks source link

Some confusion about distance measurement #18

Open LP940708 opened 4 years ago

LP940708 commented 4 years ago

Thank you for your outstanding contribution, but I have some confusion about distance measurement: (1) According to the formula: distancei = (2 x 3.14 x 180) ÷ (w + hx 360) x 1000 + 3, if the same person is detected, it is obvious that the w, h of the bbox of the face is much smaller than that of the pedestrian bbox, according to the formula, the calculated distancei of the face is much farther than the pedestrian, but they belong to the same person at the same depth. The calculated result does not seem to be in accordance with common sense. Does the formula have any restrictions? (2) How is the formula d = f + R / r inferred? (3) Why is focal length a constant? (f=2x3.14x180/360) Thank you very much for your enthusiastic answer!

paul-pias commented 4 years ago

There is no issue with the distance measurement formula. The problem that you mentioned in the first question is a logical one. The performance of the distance measurement formula relies on how the object detector is deciding the saliency of an object. For example if you are using YOLOv4 to detect a person and MTCNN/Retinaface to detect the face then both the model will not perform in a similar manner which will create the problem you mentioned.

For question 2 & 3 you can see my answer on this issue Thank you!

HassanBinHaroon commented 2 years ago

Check out the following relevant and easiest implementation.

https://github.com/HassanBinHaroon/object_detection-PLUS-distance_estimation-v1