Skip to content

AnxiousCodeGeek/Distance-in-Video

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Distance Estimation in a MP4 Video

The function estimates distance in a mp4 video. I tested it on dashcam videos from Youtube.

Function

def estimate_distance(bbox_width):
    focal_length = 1000  # Example focal length in pixels
    known_width = 2.0  # Known width of the vehicle in meters
    distance = (known_width * focal_length) / bbox_width
    return distance

Explanation

The logic behind this distance estimation is processing of video frame by frame. The frame window is considered as the camera and distance in pixels is estimated from the objects in the video that move frame by frame.

When using the function in image callback or process video functions:

bbox_width = x2 - x1
distance = estimate_distance(bbox_width)

Example:

Example Image
Example Image

Note:

The images were taken from UDACITY.

About

The function estimates distance in a mp4 video.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published