Giter Site home page Giter Site logo

carstopdetection's Introduction

Overview

I already have a repo for car counting and tracking but here I decided to detect car stop.

So this repo is based on CarCounterYOLOv3 with some changes in it's structure and code.


At the very beginning a thought that it was enough just to check if centroid coords on N and N+1 frames are the same. That would indicate that a car is standing still.

BUT

YOLOv3 works not perfectly and even if I can see that the car is not moving it's centroid is "shaking" on the video. That means that it's coords won't be exactly the same of two different frames.

So I decided to consider a car not moving if it's centroid's coords are SLIGHTLY changing but are still not very different on separate frames.

So how it works:

  • If distance between car centroid's coords on 1 and 2 frames is shorter than a minimum (we can change it) then we put this centroid in a dictionary.
  • Dictionary looks like this ID (key) -> Number of frames on which distance that I was talking about above is "kept"(value)
  • If on the 3rd frame situation is the same (distance is small) than the number of frames increases. And so on...
  • If this continues for some time (or some amount of frames) then we can tell that the car is stopped.
  • If after decreasing the distance starts increasing than we can tell that the car is moving again.

(for more detailed explanation see comments in code)

How to run it:

  • Clone/Download this project.
  • Download YOLOv3 .weights here and put it to /yolo folder
  • Get all necessary modules via `pip install -r 'requirements.txt'.
  • Go to the directory with this project.
  • Download some videos of cars driving aroud o just use a test video01.mp4 that I've uploaded.
  • Type python car_stop_detector.py -y yolo --input videos/'PATH_TO_YOUR_VIDEO'.mp4 --output output --skip-frames 5 and hit Enter.
  • Enjoy!

carstopdetection's People

Contributors

creestl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

carstopdetection's Issues

i got some error while trying to run the code.

args = vars(ap.parse_args())
Exception has occurred: SystemExit
2

i cant install dlib module to

i am so grateful if you can reply ASAP and help me to fix this problem. Thanks
i need to use the code next week.

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.