This project estimates the speed of objects in a video using YOLOv9 for object detection and DeepSORT for tracking. The estimated speeds are overlaid on the video along with bounding boxes around the detected objects.
- Clone this repository:
git clone https://github.com/kardSIM/Vehicle_Speed_Estimation.git
cd Vehicle_Speed_Estimation
- Create new environment:
- Using Conda
conda env create -f conda.yml
conda activate yolov9-deepsort
- Download input video:
mkdir content
wget -P content https://github.com/AarohiSingla/Speed-detection-of-vehicles/raw/main/highway.mp4
wget -P content https://github.com/AarohiSingla/Speed-detection-of-vehicles/raw/main/highway_mini.mp4
- Run:
python object_tracking.py
-
Prepare the video file:
- Place the video file in the desired location.
- Update the
video
argument in the path of the video file.
-
Configure the output video:
- Update
output
argument in the code to specify the path and filename of the output video file.
- Update
-
Transforming Road Image to Bird's Eye View:
- Update the source points
SOURCE_POLYGONE
and destination pointsBIRD_EYE_VIEW
corresponding to the appropriate dimensions of the road.
- Update the source points
-
Set the confidence threshold:
- Adjust the
conf
argument in the code to set the confidence threshold for object detection. Objects with confidence below this threshold will be filtered out.
- Adjust the
-
If you want to detect and track certain object on video
- Modify the
class_id
argument in the code to specify the class ID for detection. The default value is set to None.
- Modify the
-
If you want to blur certain object while tracking
- Modify the
bulr_id
argument in the code to specify the class ID for detection. The default value is set to None.
- Modify the
-
Run the code:
# Run object tracking python object_tracking.py # Run on another file python object_tracking.py --video ./data/test.mp4 --output ./output/output.mp4 # Run car tracking (set class_id to 2 for car) python object_tracking.py --class_id 2 # Run tracking on a video with burring certain objects (set blur_id to 7 for truck) python object_tracking.py --blur_id 7
- This code is built upon the YOLOv9 model and the DeepSort algorithm.
- Credits to the authors and contributors of the respective repositories used in this project.