Build Ai car and pedestrian tracking for beginners using Python


Author | Nidhi punj
Compile Flin
Source | medium

Step 1: get a lot of car pictures

Step 2: turn them all into black and white pictures

Grayscale images make the algorithm faster. Color increases the complexity of the model, or we can say that gray images are used to simplify mathematics. For example, we can talk about brightness, contrast, edge, shape, outline, texture, perspective, shadow, etc. instead of color.

Step 3: train the algorithm to detect the vehicle

Now the question comes: how do computers train algorithms?

We just found a match.

We can match the above functions to actually detect the rear bumper of the car, as shown below.

The idea of detecting pedestrians is the same

Everything is to match features or shapes. If an object matches the above features, the model will detect it as a pedestrian.

Let’s start writing detectors

Step 1: we first need to install the opencv library.

pip install opencv-python

If this does not work, try:

pip install opencv-python-headless

If you still can’t install. Try using Google search. How do I install opencv on my computer?

Step 2: download the machine learning file (Haar cascade XML file):

We have provided a pre trained car and human (pedestrian) classifier. We just need to download it.

Vehicle pre training classifier

Human pre training classifier

Step 3: we only need to write 20 lines of code. You can understand it by reading the code.

GitHub code link:


View video:

Recommended links:

Original link:

Welcome to panchuang AI blog:

Official Chinese document of sklearn machine learning:

Welcome to panchuang blog resources summary station: