• Stars
    star
    851
  • Rank 51,804 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿš˜ "MORE THAN VEHICLE COUNTING!" This project provides prediction for speed, color and size of the vehicles with TensorFlow Object Counting API.

VEHICLE DETECTION, TRACKING AND COUNTING

This sample project focuses on "Vechicle Detection, Tracking and Counting" using TensorFlow Object Counting API. Please contact if you need professional vehicle detection & tracking & counting project with the super high accuracy!


The TensorFlow Object Counting API is used as a base for object counting on this project, more info can be found on this repo.



The developing is on progress! This sample project will be updated soon, the more talented traffic analyzer app will be available in this repo!


General Capabilities of This Sample Project

This sample project has more than just counting vehicles, here are the additional capabilities of it:

  • Detection and classification of the vehicles (car, truck, bicycle, motorcycle, bus)
  • Recognition of approximate vehicle color
  • Detection of vehicle direction of travel
  • Prediction the speed of the vehicle
  • Prediction of approximate vehicle size
  • The images of detected vehicles are cropped from video frame and they are saved as new images under "detected_vehicles" folder path
  • The program gives a .csv file as an output (traffic_measurement.csv) which includes "Vehicle Type/Size", " Vehicle Color", " Vehicle Movement Direction", " Vehicle Speed (km/h)" rows, after the end of the process for the source video file.

ToDos:

  • More powerful detection models will be shared.
  • Sample codes will be developed to process different types of input videos (for different types of road traffics such as two way lane road).
  • Code cleanup will be performed.
  • UI will be developed.

The input video can be accessible by this link.

Theory

System Architecture

  • Vehicle detection and classification have been developed using TensorFlow Object Detection API, see for more info.
  • Vehicle speed prediction has been developed using OpenCV via image pixel manipulation and calculation, see for more info.
  • Vehicle color prediction has been developed using OpenCV via K-Nearest Neighbors Machine Learning Classification Algorithm is Trained Color Histogram Features, see for more info.

TensorFlowโ„ข is an open source software library for numerical computation using data flow graphs. Nodes in the graph represent mathematical operations, while the graph edges represent the multidimensional data arrays (tensors) communicated between them.

OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products.

Tracker

Source video is read frame by frame with OpenCV. Each frames is processed by "SSD with Mobilenet" model is developed on TensorFlow. This is a loop that continue working till reaching end of the video. The main pipeline of the tracker is given at the above Figure.

Model

By default I use an "SSD with Mobilenet" model in this project. You can find more information about SSD in here. See the detection model zoo for a list of other models that can be run out-of-the-box with varying speeds and accuracies.

The minimum vehicle detection threshold can be set in this line in terms of percentage. The default minimum vehicle detecion threshold is 0.5!

Project Demo

Demo video of the project is available on My YouTube Channel.

Installation

Docker setup with Nvidia GPU: Run the demo in the GPU without installing anything, just nvidia-docker. The command to set up this docker:

docker-compose up

Alternative for nvidia-docker, you can follow the installation steps are given below!

1.) Python and pip

Python is automatically installed on Ubuntu. Take a moment to confirm (by issuing a python -V command) that one of the following Python versions is already installed on your system:

  • Python 3.3+

The pip or pip3 package manager is usually installed on Ubuntu. Take a moment to confirm (by issuing a pip -V or pip3 -V command) that pip or pip3 is installed. We strongly recommend version 8.1 or higher of pip or pip3. If Version 8.1 or later is not installed, issue the following command, which will either install or upgrade to the latest pip version:

$ sudo apt-get install python3-pip python3-dev # for Python 3.n

2.) OpenCV

See required commands to install OpenCV on Ubuntu in here.

3.) TensorFlow

Install TensorFlow by invoking one of the following commands:

$ pip3 install tensorflow     # Python 3.n; CPU support (no GPU support)
$ pip3 install tensorflow-gpu # Python 3.n; GPU support

Current program is compatible with TensorFlow 1.5.0 version. Please uncomment these lines to run the program with TensorFlow 2.x: #1, #2, #3, #4.

4.) TensorFlow Object Detection API

See required commands to install TensorFlow Object Detection API on Ubuntu in here.

If you are still getting problem about installation after completed the installation of the packet that are given above, please check that link out to get detailed info about installation.


How to run the program?

After completing these 4 installation steps that are given at above, you can test the project by one of these commands. Program takes an input argument 'imshow' or 'imwrite':

  python3 vehicle_detection_main.py imshow
  python3 vehicle_detection_main.py imwrite
  • imshow : shows the processed frames as an video on screen.
  • imwrite : saves the processed frames as an output video in the project root folder.

Citation

If you use this code for your publications, please cite it as:

@ONLINE{vdtct,
    author = "Ahmet ร–zlรผ",
    title  = "Vehicle Detection, Tracking and Counting by TensorFlow",
    year   = "2018",
    url    = "https://github.com/ahmetozlu/vehicle_counting_tensorflow"
}

Author

Ahmet ร–zlรผ

License

This system is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

tensorflow_object_counting_api

๐Ÿš€ The TensorFlow Object Counting API is an open source framework built on top of TensorFlow and Keras that makes it easy to develop object counting systems!
Python
1,305
star
2

signature_extractor

A super lightweight image processing algorithm for detection and extraction of overlapped handwritten signatures on scanned documents using OpenCV and scikit-image.
Python
414
star
3

color_recognition

๐ŸŽจ Color recognition & classification & detection on webcam stream / on video / on single image using K-Nearest Neighbors (KNN) is trained with color histogram features by OpenCV.
Python
301
star
4

augmented_reality

๐Ÿ’Ž "Marker-less Augmented Reality" with OpenCV and OpenGL.
C++
204
star
5

defi_yield_farming

๐Ÿšœ ๐ŸŒพ A DeFi app, which provides staking & farming functions are deploy-able with a website, for yield farming.
JavaScript
142
star
6

face_recognition_crop

Multi-view face recognition, face cropping and saving the cropped faces as new images on videos to create a multi-view face recognition database.
Python
139
star
7

vehicle_counting

Vehicle detection, tracking and counting by blob detection with OpenCV on c++.
C++
116
star
8

vehicle_counting_hog_svm

Vehicle detection, tracking and counting by SVM is trained with HOG features using OpenCV on c++.
C++
96
star
9

aipa

AIPA (A.I. Personal Assistant): Speech, Vision, Machine Learning and IoT based intelligent personal assistant for Ubuntu based Linux distributions.
Python
48
star
10

real_time_circle_detection_android

Real time circle detection and tracking by Hough Circle Transform with OpenCV on Android OS.
Java
44
star
11

human_computer_interaction

Fist, palm and hand detection & tracking for intelligent human-computer interaction game character movement control with OpenCV on Java (Processing sketchbook).
Processing
44
star
12

unity_calendar_ui

This is a well defined-basic "Calendar UI" for Unity.
C#
24
star
13

arlo_traffic_analysis

Vehicle detection, tracking, counting and speed prediction on videos with OpenCV.
Python
19
star
14

nonlinear_regression_keras

Training of a neural network for nonlinear regression prediction with TensorFlow and Keras API.
Jupyter Notebook
15
star
15

tcp_socket_programming_android_client

TCP Socket Programming implementation of client side on Android.
Java
12
star
16

smart_contract_helloworld

๐Ÿ”ฅ Smart contract hello world tutorial: write and deploy your first Ethereum smart contract!
Solidity
9
star
17

decentralized_banking_system

๐Ÿฆ Decentralized banking system is a DApp built on Ethereum blockchain with smart contract on solidity.
Solidity
9
star
18

object_detection_chooch

A sample project for super fast real time object detection and counting using CHOOCH AI API and OpenCV.
Python
9
star
19

unity_camera_movements

"Main Camera" movements scripts for Unity (for Desktop and Gear VR platforms).
C#
8
star
20

tcp_socket_programming_c_server

TCP Socket Programming implementation of server side in c programming language.
C
8
star
21

the_smart_contract_burger_store

๐Ÿ” ๐ŸŸ A real life case study for developing Ethereum smart contract for businesses: Building a smart contract to manage a burger store.
JavaScript
8
star
22

tensorflow_blob_analysis

A sample project to perform blob analysis on images with TensorFlow and Keras to detect blobs and analyze their shape features such as the presence, number, area, position, length, and direction of lumps.
Python
8
star
23

family_tree_warehouse_app

Ask relation, add/delete/update person, get information of any person, print the family tree, control under 18 age marriage and more...
Python
7
star
24

EncryptedMessengerApplication

Encrypted Messenger App: Sending and receiving messages (over TCP Socket) with high security (powered by RSA and AES).
Java
5
star
25

android_power_monitor

๐Ÿ”‹ Android power monitor hardware with Arduino.
C++
4
star
26

java_native_interface

Java Native Interface to call "Java Code" from "C++ Program".
C++
3
star
27

family_tree

Ask relation, add/delete/update person, get information of any person, print the family tree, control under 18 age marriage and more...
Prolog
3
star
28

ahmetozlu.github.io

1
star
29

pattern_matching

Implementation and performance comparison of Boyer Moore, Horspool and Brute Force in c programming language.
C
1
star
30

ethereum-smart-contract-samples

๐Ÿ’ก Small smart contract examples to understand basics and some details of developing Ethereum smart contracts!
Solidity
1
star
31

SimpleShell

This program is about a simple shell. The shell accepts user commands and then executes each command in a separate process.
C
1
star
32

sample_spring_microservice_case_study

๐Ÿฆ… An inventory management project for providing a sample microservice case study which contains Spring Cloud Eureka server & client, feign client, error handling & fault tolerance, API gateway, Spring Actuator, distributed log trace with Zipkin, centralized configuration and vault integration with Spring Cloud Config.
Java
1
star