FarrandTom / social-distancing

:star: An easy end-to-end social distancing implementation created using OpenCV! :camera:
16 stars 4 forks source link

Safe distance = ? #2

Closed ZIKO94ZIKO closed 4 years ago

ZIKO94ZIKO commented 4 years ago

Hi , thank you for you for making this project open source , i want to know whats is the safe distance implemented in your code ? and how you calculated this distance . thanks in advance

FarrandTom commented 4 years ago

Hi @ZIKO94ZIKO,

Thanks for the question. The safe distance implemented in this code is based on the PHYSICAL_DISTANCE parameter set in the settings.json file. At the moment this value is set to 100cm, meaning that everyone has an approximately 100cm ellipse radius drawn around their heads. This results in a 200cm social distance being maintained.

The real world distance of 100cm is estimated based off the size of the detected object. In the example I've posted we're detecting human heads (this allows us to check for masks too) which have been approximated to be 22.5cm in height (REFERENCE_HEIGHT again in settings.json). Using this head height estimate and the bounding box coordinates we can calculate a conversion for each person which approximates the number of pixels per 1 cm. From that I can scale up to 100cm to figure out the size of the ellipse to draw.

Hopefully that makes sense.

Cheers! Tom