This paper discusses a method for measuring traffic congestion at road intersections using a smart traffic light system, utilizing image processing techniques. A new algorithm employing background subtraction and foreground extraction is proposed to improve vehicle counting accuracy, which subsequently informs traffic light timing based on congestion levels. Results indicate high accuracy in various weather and lighting conditions, potentially reducing wait times on congested roads.