Vehicle Detection And Counting Using OpenCv | Vehicle Counting using OpenCV | Python

preview_player
Показать описание
Introduction
I worked on a video-based vehicle counting system (VCS). I shared a demo on Instagram that went viral!
In this video, I’ll explain why and take you through how I built it, discussing how it works, how I learned the libraries used, the components of the system, algorithms and models I experimented with and the results obtained. Let’s get started!
I built a video-based vehicle counting system using Python/OpenCV. You can find the code on my Google Drive Link below.

Source Code & Link.

How it works
The vehicle counting system I built 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 the trackers periodically to ensure that they are still tracking the vehicles correctly. The counter counts vehicles when they leave the frame or makes use of a counting line drawn across a road.

Why vehicle counting?
Computer Vision (CV) had been on my list of things to learn for a long time so I decided to use the opportunity of my final project to learn it. I actually wanted to build a turn-based or real-time strategy game that used a healthy dose of AI but I knew I wouldn’t have been able to complete it in time for my defence so I figured a CV project was the way to go as I’d very likely get to use Machine Learning (ML).
Computer Vision is an interdisciplinary field concerned with giving computers the ability to “see” or be able to understand the contents of digital images such as photos and videos. While vision is a trivial task for humans and animals, it’s currently quite difficult for machines. However, a lot of progress has been made in the field in the last few decades and new techniques and technologies to make CV faster and more accurate are actively being researched.

A vehicle counting system, as you might have already inferred, is a system that counts vehicles on the road. Why would you want to build one? Why would you want to count vehicles on the road? Here are some reasons:
Traffic management and planning
Traffic control
Parking management
Advertising

Why video?
There are a handful of ways to count vehicles on the road from manual counts to pneumatic tubes to piezoelectric sensors. Why was video used? Why is it preferred?

Sensor data (video footage) can be used to verify the system’s results which makes it easier and faster to evaluate and improve the system.
The footage can also be used for other purposes including surveillance, automatic plate number recognition, vehicle type detection and vehicle speed detection to name a few.
It is relatively cheaper to implement and scale as a permanent vehicle counting system compared to other systems.
It can track and count multiple vehicles moving in different directions across several lanes.

Algorithm Used here is BackgroundSubtractorMOG.

I will put one more video to explain the full code if you are getting any error while running this program please let me know in command section I will clear it.
Thank you Have a Good Day.

For more PYTHON videos:

1) Real-Time Face recognition

2) Smile Detector Using python

3)Face and Eye detection Using python

4)Fire detection using python.

5)Bird Detection Using python

6)Face recognition based attendance system

#Vehicledetection, #Python, #Vehicledetectionpython, #Vehicledetectionusingopencvpython, #Opencvpythontutorial, #Opencvpython, #Opencv, #Vehiclecountingopencvpython, #Vehiclecountingpython

***

Follow Me Here For More Help or Queries


***

SUBSCRIBE for weekly videos on Programming Language, Technology, Science, Space, and Many More.
Рекомендации по теме
Комментарии
Автор

THANKS for that code. All I needed is a program that will just count cars in real time. And all tutorials I was able to found was just like "Write the code by urself". AND i found You! THANK YOU VERY MUCH!!

глокКэт
Автор

Thank q for the video, how to get the output of video, i am getting the error of
(subtracao =
AttributeError: module 'cv2.bgsegm' has no attribute can you please tell me about this..?

vasanthsai
Автор

hi if i want to count the fish in the tank, what should i change?

tuongautomation
Автор

Great tutorial. How can we just count one side of road ? Thanks...

oktoreno
Автор

I hope you will upload a video explaining the code as soon as possible.
Please ❤

rahatkhan
Автор

amazing sir . kindly share camera details which you are using sir.

Inspiration_video
Автор

Its very fantastic sir! but sir i am doing it on google colab nd theres showing an error in 'grey = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)' in this line...error: OpenCV(4.1.2) error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'..this is the prb sir...how can i solve it?? & can u sir plz provide me the link of the explanation video..i really need it

shreyasarkar
Автор

Sir, how to do programming for collision warning by estimating other vehicle distance

shubhamgaygol
Автор

Hi I am working on car parking system, so there are two lanes one for entering in and other for out.I just want to show count of available car parking space in my parking system that if car enters then count will decrement and if car leaves the count will increment.Please help

__blank__
Автор

thank u for sharing this u help me with this error : AttributeError: module 'cv2.cv2' has no attribute 'bgsegm'

tahminasultana
Автор

Traceback (most recent call last):
line 26, in <module>
subtracao =
AttributeError: module 'cv2.cv2' has no attribute 'bgsegm'

marcioleandrogoncalves
Автор

why is the thumbnail misleading? the picture says it can detect the the brand and type of vehicle, when your app only counts the incoming cars.

joshuatagalog
Автор

can you help me? when I run the code, it gives me an error on line 27 (subtraction = ()), this error appears here "AttributeError: module 'cv2.cv2' has no attribute 'bgsegm'"
tks!

victoroliveiradesousaleite
Автор

Thanks a lot sir for sending us source code

kprakash
Автор

Thanks for the video. Could you please update the source code with comments written?
I really need to understand the code

frankatobrahdanso
Автор

i watch this video before and after vehicle detection, the question is...
why is the video very slow when the detection works? . please explain that sir !

RizkiAgungSetiawan
Автор

Hello sir, I run this code it worked but only with that video .when I changed the video it shows wrong count.can u help me to make the code work for love and any

HarshaSravani--c
Автор

Sir, I am planning to do smart traffic control system using opencv software, is it possible to detect number of vehicles and accordingly give command to set traffic signal, in real time
I am not started studying it, I want to be confirmed before putting my efforts, plz reply sir🙏

akashamin
Автор

hello sir i want to count the number of vehicle from another line how can i do it sir

rajangurung
Автор

sir please make video on explaination of this source code. Comments in project are also not in english..

saikumarbolamwar
visit shbcf.ru