Git Product home page Git Product logo

car-counting-and-speed-estimation-yolo-sort-python's Introduction

vehicle-counting-and-speed-estimation-yolo-sort-python

This project uses YOLOv3 for Vehicle detection and SORT(Simple Online and Realtime Tracker) for vehicle tracking

This project imlements the following tasks in the project:

  1. Vehicle counting
  2. Lane segmentation
  3. Lane change detection
  4. Speed estimation
  5. Dumps all these details into a CSV file

SCREENSHOT

link to the original video: https://youtu.be/PSf09R3D7Lo

link to the ouput video:https://drive.google.com/open?id=1Zci9i13Voo9KMhJQyygoZ-kYAVFiaoVQ

Note that there are 4 locations in the video and so the code(4 IFs), you can delete 3 and edit the first one according to your need.

To run the project:

  1. Download the code or simply run:
$ git clone https://github.com/bamwani/car-counting-and-speed-estimation-yolo-sort-python 
  1. To install required dependencies, run:
$ cd car-counting-and-speed-estimation-yolo-sort-python/
$ pip3 install -r requirements.txt
  1. Download yolo weights file by:
$ bash download_weights
  1. Make sure you change the line of detection and lane segmentation according to your video and fine tune the threshold and confidence for YOLO model

  2. Run

$ Python3 main.py -input /path/to/video/file.avi -output /path/for/output/video/file.avi -yolo /path/to/YOLO/directory/

Speed Detection:

This is an interesting project, mainly due to camera shaking(maybe due to wind or whaterver the reason may be!). This camera shake results into frame flickering. Which means we can not use traditional pixel distance travelled to Km/h mapping because as each frame flickers, the centroid of the bounding box also flickers arbitrarily. Hence I tried this new method: SPEED BETWEEN TWO LINES

Speed Between Two Lines (SBTL)

This method makes some assumptions which are as follows:

  1. We know the speed limit of the road for which the video is recorded/streamed.
  2. Atleast one vehicle is driving at the speed limit.

--> We draw two lines on the frame perpendicular to the vehicle moving directon, then we find the minimim time taken by any car to cross these two lines(This car will be moving at the speed limit). Once we find he minimum time required for a car to pass these two lines, we use simple speed=distance/time formula to calculate the speed for rest of the cars.[ I know this wouldn't be perfect, but surely much more precise than the pixel mapping method]

I will try to keep making commits to improve the speed detection of vehicles. Any pull request for improvement is highly welcomed.

References:

YOLO

SORT Algorithm

Reference for combining YOLO and SORT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.