- Vehicles count for each lane
- Pedestrians in either direction
- Video time of entry of road user
The given dataset has 4953 frames at ~10fps with (width,height) = (1280,720)
- Extract images from video
- Detect all types of vehicles in the video
- Counting vehicles
- Pedestrian detection
- Track pedestrians over crossing and count them
- Stabilize the count of vehicles
- Add time information
- Find direction of pedestrian crossing
All the code has been developed and tested on Linux Ubuntu 16.04 with 410.104 Nvidia driver and Cuda version 10.0 on GeForce GTX 1050. Assuming the videos are taken from the same camera facing the same road, similar to the given video.
Major Dependencies
- Opencv (version>3)
- Keras
- Numpy
- PyTorch
Method
Track the traffic participants continuously through the frames for a stable count. DeepSort link has been used for tracking vehicles and pedestrians with Yolov3 framework for object detection. Since the focus is not on lane detection/classification, it is taken as given (i.e we have information about lanes and zebra crossing).
Vehicle is counted corresponding to the lane it is present in. The vehicle is tagged when observed for the first time in the frame and is continuously tracked to avoid duplicate count.
Pedestrian's crossing is taken as the direction that is opposite to where he/she was found in the frame for the first time.
Tesseract OCR has been used to get timestamp details from the video.
Run the following commands
git clone [email protected]:meenakshiravisankar/pytorch_objectdetecttrack.git
cd pytorch_objectdetecttrack
bash setup.sh
cd config
bash download_weights.sh
To run the script
python3 traffic_tracker.py --input <path-to-video> --output(optional) <path-to-video> --activity(optional) <directory-to-save-log>
Sample Output Video
Sample output for 1-minute part of the given video link
Directory Structure
Path | Description |
---|---|
pytorch_objectdetecttrack | Main folder |
├ subfolders & files | Tracker files |
files | Data folder |
├ results | Contains results |
├ videos | Contains input video |
├ 1569843500.mp4 | Given video |
├ raw60.mp4 | 1 min video |
- Pedestrian on the sidewalk but far interferes with the counting
- Bicycles and motorcycles - people get detected multiple times
- Whenever the tracking fails, counts are unstable