Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Kalebu/Real-time-Vehicle-Dection-Python

Repository files navigation

Hi guys, This repository consist of a source code of script to detect cars in a video/camera frame and then draw rectangaluar boxes around them.

The ML algorithms used for detecting cars and bounding boxes coordinates is a pretrained cascade model Haarcascade car.

Become a patron

Where is the full article ?

The full article for this project is originally published on my blog with an article with title Real-time vehicle detection in python

Getting started

Firstly we have to clone the project repository or download the zip of project and then extract it.

git clone https://github.com/Kalebu/Real-time-Vehicle-Dection-Python
cd Real-time-Vehicle-Dection-Python
Real-time-Vehicle-Dection-Python ->

Dependencies

Now once we have the project repo in our local directory, now lets install the dependecies required to run our script

pip install opencv-python

Sample video

The sample video we used in this project is cars.mp4 which will come as you download or clone the repository, to load a different video with different filename, you might wanna change the source code a bit.

def Simulator():
 CarVideo = cv2.VideoCapture('cars.mp4') # change cars.mp4 to name of your vidoe
 while CarVideo.isOpened():
 ret, frame = CarVideo.read()
 controlkey = cv2.waitKey(1)
 if ret: 
 cars_frame = detect_cars(frame)
 cv2.imshow('frame', cars_frame)
 else:
 break
 if controlkey == ord('q'):
 break
 CarVideo.release()
 cv2.destroyAllWindows()

running our script

Now you can launch your scripts;

python app.py 

If you use the provided sample video, your script is going to look as shown in the picture below;

drawing

Issues ?

Are you facing any issue while trying to run the script, well then raise an issue and I will do my best fixing it as soon as I can

Credits

All the credits to kalebu

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 3

Languages

AltStyle によって変換されたページ (->オリジナル) /