{"id":1509,"date":"2015-09-18T17:05:59","date_gmt":"2015-09-18T21:05:59","guid":{"rendered":"https:\/\/blogs.mathworks.com\/iot\/?p=1509"},"modified":"2018-02-22T17:37:36","modified_gmt":"2018-02-22T22:37:36","slug":"counting-cars-and-analyzing-traffic-with-thingspeak","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/iot\/2015\/09\/18\/counting-cars-and-analyzing-traffic-with-thingspeak\/","title":{"rendered":"Counting Cars and Analyzing Traffic"},"content":{"rendered":"<p>The power of any tool becomes magnified when you start combing it with other tools. In <a href=\"https:\/\/www.mathworks.com\/\/matlabcentral\/fileexchange\/52456\" target=\"_blank\" rel=\"noopener\">this File Exchange project<\/a> by Eric Wetjen, he demonstrates a powerful project by using a webcam to gather live traffic video of Route 9 in Natick, MA, using Simulink to deploy a car-counting algorithm to a Raspberry Pi, using MATLAB to perform analysis, and using <a href=\"https:\/\/thingspeak.com\" target=\"_blank\" rel=\"noopener\">ThingSpeak<\/a> to collect and share the analyzed data with others.<\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/\/matlabcentral\/fileexchange\/52456\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-1510\" src=\"https:\/\/blogs.mathworks.com\/iot\/wp-content\/blogs.dir\/15\/files\/2015\/09\/car_counting_camera.jpg\" alt=\"Car Counting Camera\" width=\"361\" height=\"483\" \/><\/a><\/p>\n<p>The project uses a Raspberry Pi 2 and USB webcam acting as a sensor. The webcam picks up traffic flowing in both directions. Once the algorithm for detecting cars is modeled in Simulink, the algorithm gets deployed on the Raspberry Pi.\u00a0The Raspberry Pi sends the raw data to ThingSpeak on regular basis where it is analyzed using the MATLAB Analysis app on ThingSpeak.<\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/\/matlabcentral\/fileexchange\/52456\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-1511\" src=\"https:\/\/blogs.mathworks.com\/iot\/wp-content\/blogs.dir\/15\/files\/2015\/09\/MATLAB_car_counting_display.png\" alt=\"MATLAB_car_counting_display\" width=\"506\" height=\"143\" \/><\/a><\/p>\n<p>After sending to ThingSpeak, Eric created a MATLAB Analysis app to calculate the\u00a0daily traffic-volume on <a class=\"external\" href=\"https:\/\/thingspeak.com\/channels\/51671\" target=\"_blank\" rel=\"noopener\">ThingSpeak Channel 51671<\/a>. Now that the data is public, others could use this processed data within apps such as Waze to optimize directions using analyzed traffic flows.<\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/\/matlabcentral\/fileexchange\/52456\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1512\" src=\"https:\/\/blogs.mathworks.com\/iot\/wp-content\/blogs.dir\/15\/files\/2015\/09\/traffic_analysis_final.png\" alt=\"MATLAB Traffic Analysis ThingSpeak Visualization\" width=\"500\" height=\"375\" \/><\/a><\/p>\n<p>Check out the <a href=\"https:\/\/www.mathworks.com\/\/matlabcentral\/fileexchange\/52456\" target=\"_blank\" rel=\"noopener\">article<\/a> for the complete project details and all of the code to get your Raspberry Pi + ThingSpeak analysis project started.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/iot\/wp-content\/blogs.dir\/15\/files\/2015\/09\/car_counting_camera.jpg\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>The power of any tool becomes magnified when you start combing it with other tools. In this File Exchange project by Eric Wetjen, he demonstrates a powerful project by using a webcam to gather live&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/iot\/2015\/09\/18\/counting-cars-and-analyzing-traffic-with-thingspeak\/\">read more >><\/a><\/p>\n","protected":false},"author":148,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[258,256,3],"tags":[214,60,23,209,161,262,212,213],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/1509"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/users\/148"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/comments?post=1509"}],"version-history":[{"count":6,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/1509\/revisions"}],"predecessor-version":[{"id":2318,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/1509\/revisions\/2318"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/media?parent=1509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/categories?post=1509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/tags?post=1509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}