Inspiration

Fighting against Covid-19 has resulted in many changes — both large and small — in the way we live our lives. In order to slow the spread of the virus, it has become important for businesses and public establishments to limit and keep track of the number of people in certain enclosed areas. This is not often an easy task, requiring an attendant stationed at each entrance at all times. Furthermore, such an approach puts the attendants at greater risk of contracting the virus themselves. There is a clear need for the automation of tracking and counting the exact number of people that enter or leave an area.

What it does

Room Counter is an automated system for detecting, tracking, and counting the number of people that enter or leave a room. Users will place a laptop with its webcam observing an entryway, and our machine learning and tracking algorithm will run behind the scenes to detect occupants coming and going. A live video feed displays the webcam footage with the detections overlaid as they appear.

How we built it

First, we trained and deployed a compact object detection neural network in pytorch to detect people in the frame. We used the well known MS COCO and pascalvoc datasets to train our model on an nvidia GPU. Then, we implemented a real-time tracking algorithm in python to process incoming video data and object detections to count when people enter or leave the room. Lastly, we use tkinter and opencv to display a simple, intuitive GUI.

Challenges we ran into

We faced many challenges during the implementation of this app. First, we had to train a model that was both fast enough to run on a laptop CPU at a usable fps, while also being accurate and robust enough to support the tracking algorithm. We also struggled with the GUI. It was hard to find a way to stream video in real time while processing the video in the background.

Accomplishments that we're proud of

We are very pleased with the back-end of the app, given the limited time we had. The neural network we trained is lightweight, but still accurate enough to produce reliable results. We are also glad that we found a solution for effectively displaying the video feed. Though our GUI is simple, it gets the job done.

What we learned

We need to become more familiar with GUI frameworks in python so that we can build front ends with more features faster. Also, it is one thing to have functioning code in the back-end, and an entirely other thing to have that code be effectively deployed in the front-end. We spent a lot of time on our back end, and we ended up cutting it really close with the functionalities of our front-end. In the future, we need to give accurate consideration and planning for all aspects of our project instead of just the most obvious ones.

What's next for Room Counter

Given more time, we will be able to train a better, more robust neural network -- this will make our tracking and counting even more reliable. We would also like to add additional functionalities to our app, such as displaying occupancy statistics over time, or even communicating with other devices to cover several entrances and exits together. We see great potential and wide applicability in this project.

Share this project:

Updates