Giter Site home page Giter Site logo

people-tracker-yolo's Introduction

Person Tracker and Counter

This project intends to build a people detection and tracking pipeline to detect and track people across a camera feed. People are tracked once the YOLO network detects it. Users can either use IP camera streams or input video to do the inference. Tracking is done with dlib tracker.

Inference flow

Since IP camera streams are used, latency in frames can occur. This leads to frame drops and frozen script. To avoid this, the WebCamVideostream class from imutils package is used. The captured frame is send to the YOLO model for inference, where it detects people and corresponding centroids are calculated. The centroids are passed to the dlib tracker for id generation and tracking.

Requirements

  1. OpenCV 3.4
  2. Tensorflow 1.7.0
  3. Keras
  4. PIL
  5. imutils
  6. logging
  7. Mongo DB
  8. pymongo
  9. dlib

Running the tracker

This pipeline relies on a configuration maintained in a Mongodb collection to access the video input. Data for building this collection is available in the 'config.txt' file.

Steps to run the file

  1. Create a Mongodb database named 'Main_DB'
  2. Create a colletion named 'cam' and write the data in 'config.txt' to a new document in 'cam' (modify the content according to your usage)
  3. Optional: create an environment to install the required packages and activate it.
  4. Clone this repo then, download and extract the model_data.
  5. Run the script as python person_tracker.py

Note

The counter logic is implemented based on the ID generated by the tracker. The algorithm splits the frame area into two halfs, along the width of the image. Image is considered as a cartesian plane, with lenght as the x-axis and width as y-axis. This demo assumes that people are moving vertically, along the y-axis of the image. Centroids are tracked and if the ID in a half plane switched to the next a count is logged. Entry and exit counts are managed through a flag [1 or -1]. For example in our case the lower half is denoted by flag -1 and top is denoted by 1. When the ID switches from top half to bottom half, the direction is calculated based on the same movement, whether it moved to either of the planes.

Issues

The yolo inference runs optimally on a CUDA capable NVIDIA GPU. CPU inferences are slow (which is expected behaviour) Tracker can wrongly ID a person in crowded situation or when the camera is not static. This may cause ID switching.

Future developement

Entire workflow will be switched to the OpenVINO toolkit provided by Intel which accelerates CPU inference significantly.

people-tracker-yolo's People

Contributors

vyzboy92 avatar

Stargazers

Sebastian Castañeda avatar

Forkers

amirunpri2018

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.