Traffic Light System using Raspberry Pi and OpenCV


Traffic signal system uses OpenCV for Vehicle detection in different direction and to change the signal based on vehicle density using Raspberry Pi


Vehicle detection OpenCV | Autonmous signal

Shipping : 4 to 8 working days from the Date of purchase

Package Includes:

  • Complete Hardware Kit

  • Demo Video-Embedded Below

  • Abstract

  • Reference Paper

  • PPT (20 Slides)

  • !!! Online Support !!!

99 in stock

SKU: An autonomous traffic light system using OpenCV Categories: , ,



The solution we provide for Traffic management by having a special intelligence which the images of road feed from the cameras (webcam or IP camera) at traffic junctions for real time traffic density calculation using image processing. It also focuses on the algorithm for switching the traffic lights according to vehicle density on the road, thereby aiming at reducing the traffic congestion on roads which will help lower the number of accidents. In turn, it will provide safe transit for people and reduce fuel consumption and waiting time. It will also provide significant data which will help in future road planning and analysis. In further stages multiple traffic lights can be synchronized with each other with an aim of even less traffic congestion and free flow of traffic. The vehicles are detected by the system through images instead of using electronic sensors embedded in the pavement. A camera will be placed alongside the traffic light. It will capture images sequences. Image processing is a better technique to control the state change of the traffic light. It shows that it can decrease the traffic congestion and avoids the time being wasted by a green light on an empty road. It is also more reliable in estimating vehicle presence because it uses actual traffic images.


Traffic-jam is a very big problem in developing cities, In fact it’s ever increasing day-by-day nature makes it difficult to find where the traffic density is more in real time, so that to schedule a better traffic signal control and effective traffic routing. The root cause of this can be of different situations like congestion in traffic like insufficient Road width, Road conditions due to weather, unrestrained demand, large delay of Red Light etc. While insufficient capacity and unrestrained demand are somewhere interrelated, the delay of respective light is hard coded and not dependent on traffic. Indeed, manual control is must, Therefore, in order to reduce man’s power, the need for simulating and optimizing traffic control to satisfy the increasing demand arises. Technology inย  the recent past using image processing for surveillance and safety, which is widely used in vehicle and traffic management for traveler information. The traffic density estimation can also be achieved using Image Processing.


We propose a technique that can be used for traffic control using image processing.ย  According to the traffic densities on all roads, our model will allocate smartly the time period of green light for each road. We have chosen image processing for calculation of traffic density as cameras are very much cheaper than other devices such as sensors. The proposed model is constructed as follows: We have a Raspberry Pi that is connected to 4 sets of LED that represent the traffic lights. It is the process of monitoring the traffic density of each side andย  change the signal according to the density in 2 direction.



flowchart of traffic light


ย block diagram of traffic light


  • Four cameras are connected with raspberry pi for every direction
  • Lights in each signal are connected to GPIO pins of Raspberry pi
  • The power supply should be given to raspberry pi
  • Power for the Signal light can be given using external power supply using relay switches (Here we are using LEDโ€™s as signal lights)


circuit diagram of traffic light



Each camera should be faced in each direction to monitor the traffic density by having a number of boundaries of each vehicle on the road. When the traffic density of one direction is high, green signal will turnย  in that direction and rest will be in red. Similarly, by analyzing the order of traffic density traffic signal should be changed in every direction. So that traffic signaling system becomes automatic using image processing through open CV and python.


  • Raspberry Pi
  • Camera-2 (for 2 directions)
  • LED for signals


  • Raspbian Jessie OS
  • Python
  • Open CV
  • Apache


This system makes the traffic signaling system automatic, by providing the vehicle density measurement intelligence to the system. So that there should not be any difficulties in traffic handling.


Additional information

Weight 1.000000 kg


There are no reviews yet.

Be the first to review “Traffic Light System using Raspberry Pi and OpenCV”

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.