File Exchange

image thumbnail

Analyzing Traffic Using a Webcam, a Raspberry Pi and ThingSpeak

Develop a traffic monitoring algorithm and analyze traffic data sent to ThingSpeak

62 Downloads

Updated 05 Jan 2018

View License

In this IoT project, we use a Raspberry Pi, a web cam and ThingSpeak to analyze traffic on a busy highway. With Simulink we design and deploy a traffic monitoring algorithm to the Raspberry Pi, and we analyze and visualize the traffic patterns using ThingSpeak, an IoT analytics platform, and MATLAB. This article features channel 38629 on ThingSpeak.
For more information about ThingSpeak, see https://www.mathworks.com/products/thingspeak.html

Comments and Ratings (18)

Oliver Mörth

Hello, I am using a Raspberry Pi model B and a LifeCam Studio (Microsoft) as the webcam. By increasing the resolution, I can identify more image errors (parts of the image are mixed up and not in the right position) and the counting doesn't work properly. Does anyone please know why this happens and how to solve this problem?

When I run the m file getting following error but graph appears for Traffic Density for the week starting at a particular day.

Error using reshape
Product of known dimensions, 5655, not divisible into total number of elements, 39586.

Error in traffic_analysis_final_updated_old (line 176)
dailymeaneast = mean(reshape(eastTraffic, floor(length(alltrafficData)/7),[]));

Thanks a lot M.Khan.Its working.

M.Khan

M.Khan (view profile)

SDL Video Display and FinalOutput are for debugging purpose only. To view these two displays, you need to enable the subsystem 'raspberrypi_viptrafficfd3_Density/Car Density/Enabled Subsystem'. To enable this subsystem, double click on the block 'raspberrypi_viptrafficfd3_Density/Car Density/Debug Flag' and set the Constant Value to 1. Redeploy the generated code and it should display the outputs.

Thanks for including model. when I run the model on Raspberrypi I am not getting the SDL video display output and the final output..but get the camera output.Please help.

Hans Scharler

Thanks for including the model!

has anyone re-created this model or received the original to run the experiment??

hello sir, can you ad simulink model please?

how to get the total no of vehicles

Neven Lazarov

You forgot to include the model

vcmorini

Hello,

Where is the simulink model?

Thanks

Omar Madrigal

please add the model

tendres

+1 on looking for the missing model

saeed amindin

the model missing. please add a new file with model for downloading.

where can I find this model ,I'm very intereted in this project!

Mikhail

Mikhail (view profile)

It seems that you've forgotten to share the Simulink model used for car detection.

Updates

1.2.0.0

Updated traffic monitoring algorithm and added Simulink model to the submission.

1.1.0.1

Updated description.

1.1.0.1

Updated license

1.1.0.0

Initial release.

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Communities
More Files in the  MATLAB Maker Community

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor