National Institute of Technology Karnataka, Surathkal
Deadline for SMP 2021 registration is 8th May. Register here

Traffic light Control using Image Processing


TWe implemented a system which controls the functionality of traffic lights according to the density of traffic ie., operating the traffic lights based on density of traffic along each side of the road.


The project was implemented using OpenCV and Image Processing. We take the images of each lane and compare it with an image of an empty road. Then using the ‘Similarity Index’ we decide the timer required for each lane. Then will program our traffic lights using Raspberry Pi microcontroller.


● We started out with researching the topic and got a clear understanding of the problem statement.
● We then started out working on basic OpenCV functions and later implemented edge detection algorithms.
● Then we came up with the algorithm and code for finding the ‘Similarity Index’ for different densities of cars present on the lane.
● Then we synchronized our servo motor for a perfect 3*90 degree rotation so as to click the pictures of all sides of the road using picam.
● Then we rewrote the code for Nokia LCD so as to display the remaining time available for passing the signal( ie., the time for which our signal will remain green).


The following are pictures of different cars used:

The following similarity dataset was obtained by comparing them with our code :

The link to our Image Processing Python Code, Servo Motor Code, Nokia LCD code can be found here Traffic Light Control Codes


Once we get hardware components, we have to write the code for RGB led and also the code for taking the pictures from picam and then have to merge all the codes into a final code so as to make our system work.


We have learnt to use Rpi and interface a Pi Camera module using it. We have also learnt the working of Servo motor.


Hence we started with image processing and worked on OpenCV functions and finally implemented the traffic light control using real time images of traffic and processing the data and setting the timer of each lane accordingly.



● Neha Saji - Mentor-
● Divyansh Bansal -
● Sriram Saran -