Have you ever wanted to keep track of how many people pass by a location? Have you ever wanted to see what computer vision can do for you or maybe wanted to get involved with IOT? Well, this may be the project for you!

This project uses a USB webcam and MATLAB to develop a people tracking algorithm that uses the ThingSpeak IOT platform. Here is a quick link to the video for those who are visual learners - https://www.mathworks.com/videos/creating-a-cloud-based-people-counter-using-matlab-121312.html 

Overview:

When a person's face is in front of the webcam, the program does several things:

  • Draws a bounding box around the face
  • Captions the bounding box with the Face ID number
  • Tracks the person's face throughout the video frame with the captioned bounding box
Additionally, for every 5th face detected per session, we take a picture of the user and display it on the screen with a congratulatory message for five seconds.

https://www.hackster.io/DanDoherty/cloud-based-people-counter-880ed8#toc-how-does-it-work-1How Does It Work?

Note: You must be connected to the internet in order for the people counter to transmit/receive data from ThingSpeak.
  • How are the faces tracked?
The people counter uses functions from the Computer Vision System Toolbox to detect and track the human faces. The faces are tracked based off key facial structure points and this method helps the algorithm track faces even if the face rotates in the video. This people counter is able to track multiple faces by using 'MultiObjectTrackerKLT.m' which is based upon the Kanade-Lucas-Tomasi feature tracker.
  • How is the Face ID determined?

The unique face ID is determined by reading the data in the ThingSpeak channel. The latest channel entry contains the ID of the last face that was detected so essentially ThingSpeak serves as the secretary for the people counter. To make sure we don't use invalid data, the program checks to make sure the entry was logged in the current day. If it is not from the current day, the unique face ID will start at 1. Whenever a new face is detected, the algorithm writes new data to the ThingSpeak channel which updates the face ID number.

Documentation and Demonstration

To download the project files, go to the following link: https://www.mathworks.com/matlabcentral/fileexchange/58435-creating-a-cloud-based-people-counter-using-matlab

 

PS - This is a repost from a Hackster post by my colleagues Nick and Dan