This project explores traffic light patterns using a traffic snapshot images API, introducing a new methodology for analysis. The study is divided into two parts: image processing to extract meaningful data and data analysis to derive traffic trends.
Traffic snapshot images are retrieved from the data.gov.hk platform via simple HTTP requests, updating every minute. This real-time access enables continuous monitoring and analysis of traffic light patterns for improved insights.
Google map image
Certain assumptions were made to predict traffic light statuses. When vehicles halt before an intersection, the light is assumed to be red, and when movement continues, it is likely green. However, a delay in the image feed requires precise identification of the exact capture time to accurately represent real-time traffic conditions.
"The original CCTV image resolution of 320x240 posed challenges for analysis. To enhance clarity and support further development, the image was upscaled for improved processing efficiency.
Before
After
The provided image has a delay from its actual capture time, requiring precise extraction of the timestamp for accurate analysis. The capture time is located in the bottom right corner of the image and extracted using Optical Character Recognition (OCR) technology. The extracted time code is then renamed in HHMMSS format for consistency.
"Image analysis suggests that when vehicle density is high, the red light is active, while lower traffic intensity indicates a green light. All extracted data, aligned with the recorded time code, is organized into a CSV file for further analysis.
Traffic light : RED
Traffic light: GREEN
Time | Status