The detection and tracking of objects in autonomous vehicles is essential for operation safety. There are several approaches for computing the distance between static objects. Conventional machine learning methods are using distance metrics to calculate the distance between the objects like Manhattan distance, hamming distance and Euclidean distance based on p-norm measure. But coming to the field of moving objects the focal length is the point of concern. In this paper, the object detection and also tracking of the object is worked out from the moving camera. The detection is performed based on You Only Look Once (YOLO) algorithms and the distance is calculated by finding the focal length between the object and camera. The methods tailored gave accurate results in assessing the spatial distance between the camera and the moving object.