This is a short blog about my bachelor thesis project that I wrote in 2011. The thesis was titled “Video Processing Application for Intelligent Traffic Monitoring using Optical Flow Technique.” So, what is this project about? This is what I wrote in my abstract:

Traffic jam has been a big problem in big cities of Indonesia nowadays. The police have offered a solution by placing traffic monitoring camera. But the problem arises because the camera only offers visual information. This research is trying to build a system which can extract much more useful information from the camera. The information is the average velocity of vehicle and classification of road density measured in a time interval.

and how do I did this 'measuring the road density'? Again, here is what I wrote in my abstract:

The system is built by designing computer vision software with OpenCV and set to run on a Windows computer. The computer vision software is created using optical flow technique with Pyramid Image Lucas-Kanade algorithm. The optical flow is calculating the instantaneous velocity by comparing the motion of the vehicle in two successive frames. The next step is calculating the average velocity by averaging the instantaneous velocity over a desired time interval. Then the system classifies the traffic density based on the average velocity. The traffic information can be accessed over the web in a mobile browser.

Let's elaborate a bit. Basically, what I am interested with from the CCTV video is to find how fast the vehicle is moving. This falls into the domain of object tracking in computer vision. Object tracking tries to follow the object of interests from one video frame into another. In my case, my object of interests would be cars or buses or motorbikes etc. Once you can track those vehicles, then you could compute their velocity because the vehicles are moving in each subsequent frame. The velocity is computed by calculating the displacement, how far the vehicle moves from one frame to the other. In reality, what I track is actually not the vehicle itself, but the individual pixel that makes up the vehicle. The displacement of the pixel is what is called the optical flow. There are several ways to calculate the optical flow and for my project I use the Lucas-Kanade algorithm. Below image shows the optical flow of one car.

The accuracy of the system is 78.96% at day and 41.91% at night. The system can successfully measure the average velocity and the road density of Dr. Djundjunan street in Bandung and both information can be accessed easily over a mobile browser.