Git Product home page Git Product logo

vehicle-counting's Introduction

Video-based Vehicle Counting System

Setup

  • Install Python 3 on your machine.
  • Clone this repo [email protected]:nicholaskajoh/Vehicle-Counting.git.
  • Get video footage of a traffic scene (sample videos).
  • Create and/or use a virtual environment.
  • Run pip install -r requirements.txt to install dependencies.

Run

Configuration

usage: Vehicle_Counting.py [-h] [--iscam] [--droi DROI] [--showdroi]
                           [--mcdf MCDF] [--mctf MCTF] [--di DI]
                           [--detector DETECTOR] [--tracker TRACKER]
                           [--record] [--headless] [--clposition CLPOSITION]
                           video

positional arguments:
  video                 relative/absolute path to video or camera input of
                        traffic scene

optional arguments:
  -h, --help            show this help message and exit
  --iscam               specify if video capture is from a camera
  --droi DROI           specify a detection region of interest (ROI) i.e a set
                        of vertices that represent the area (polygon) where
                        you want detections to be made (format:
                        1,2|3,4|5,6|7,8|9,10 default: 0,0|frame_width,0|frame_
                        width,frame_height|0,frame_height [i.e the whole video
                        frame])
  --showdroi            display/overlay the detection roi on the video
  --mcdf MCDF           maximum consecutive detection failures i.e number of
                        detection failures before it's concluded that an
                        object is no longer in the frame
  --mctf MCTF           maximum consecutive tracking failures i.e number of
                        tracking failures before the tracker concludes the
                        tracked object has left the frame
  --di DI               detection interval i.e number of frames before
                        detection is carried out again (in order to find new
                        vehicles and update the trackers of old ones)
  --detector DETECTOR   select a model/algorithm to use for vehicle detection
                        (options: yolo, haarc, bgsub, ssd, tfoda | default:
                        yolo)
  --tracker TRACKER     select a model/algorithm to use for vehicle tracking
                        (options: csrt, kcf, camshift | default: kcf)
  --record              record video and vehicle count logs
  --headless            run VCS without UI display
  --clposition CLPOSITION
                        position of counting line (options: top, bottom, left,
                        right | default: bottom)

Notes

Examples

Use defaults:

python Vehicle_Counting.py "./videos/sample_traffic_scene.mp4"

Custom configuration:

python Vehicle_Counting.py "./videos/sample_traffic_scene.mp4" --droi "750,400|1150,400|1850,700|1850,1050|500,1050" --showdroi --detector "haarc" --tracker "csrt" --di 5 --mctf 15

With camera input:

python Vehicle_Counting.py 1 --iscam

NB: You can press the s key when the program is running to capture a screenshot. The images are saved in the screenshots folder.

How it works

The vehicle counting system is made up of three main components: a detector, tracker and counter. The detector identifies vehicles in a given frame of video and returns a list of bounding boxes around the vehicles to the tracker. The tracker uses the bounding boxes to track the vehicles in subsequent frames. The detector is also used to update trackers periodically to ensure that they are still tracking the vehicles correctly. The counter draws a counting lines across the road. When a vehicle crosses the line, the vehicle count is incremented.

PS: You can find out about how the vehicle counting system was built by checking out this article on my blog: https://alphacoder.xyz/vehicle-counting/.

Donate

Love this project? You can buy me a coffee or two to support its continued development. ๐Ÿ˜Š

vehicle-counting's People

Contributors

nicholaskajoh avatar dependabot-preview[bot] avatar amin-tgz avatar yemikudaisi avatar

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.