traffic congestion prediction with images

11
Traffic Congestion Prediction Based on Image processing

Upload: maximilian-jackson

Post on 19-Mar-2017

169 views

Category:

Data & Analytics


2 download

TRANSCRIPT

Page 1: Traffic congestion prediction with images

Traffic Congestion Prediction

Based on Image processing

Page 2: Traffic congestion prediction with images

Overview• Objective• Packages used• Processing the images• Building the model• Testing the model• Challenges

Page 3: Traffic congestion prediction with images

Objective• Based on a image taken of the road with cars, we want to build a

machine learning model to predict the state of congestion.

Page 4: Traffic congestion prediction with images

Packages Used• Scikit-image• Scikit-learn• Matplotlib

Page 5: Traffic congestion prediction with images

Processing the images• Image of road conditions are obtained from

http://www.mytransport.sg/content/mytransport/home/dataMall.html• LTA Datamall provides access to the Traffic Camera images refreshed

every 5 minutes• Cronjob to download an image every 5 minutes.

Get the images using GET requests

Save it as a jpg by writing blocks

Sample code

Page 6: Traffic congestion prediction with images

Processing the images• Using Scikit-image, we used the Histogram Oriented Gradients algorithm to generate the features of each image.

See more about HOG here:

https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients

• Unfortunately, we had to manually label each image of the road condition : 1 (no congestion), 2(somewhat congested), 3(congested)

Page 7: Traffic congestion prediction with images

Processing the images• We generated the features based on traffic images over 7 days.• The images need to be converted to Gray-scale prior to applying the

HOG algorithmSample code

Page 8: Traffic congestion prediction with images

Processing the images• What did HOG do?• Each image generated 9,600 features

Page 9: Traffic congestion prediction with images

Building the model• So now we have our features we can build our model• Using RandomForest with 20 estimators

Sample code

Page 10: Traffic congestion prediction with images

Testing the model

Example:Accuracy: 0.929054054054Low/No Congestion [[776 1 0]Medium Congestion [ 52 21 0]High Congestion [ 8 2 28]]

We obtained some interesting results depending on the images and which road was used.

Sample code

Page 11: Traffic congestion prediction with images

Challenges• Labelling the images• Image resolution – maybe implementing some filters might help to

improve• Time of day – at night lights from the cars were creating big white

blobs. In a way it did not really matter as a white blob just meant that there was some cars there and a congestion might be occurring.• Some images downloaded were corrupted