Simple method for object distance estimation utilizing RaspberryPi Motorized Focus Camera https://github.com/ArduCAM/RaspberryPi/blob/master/Motorized_Focus_Camera/Autofocus.py
To use first select the region of interest by mouse click&drag rectangle corner and press enter.