Remote People Tracker

What Is This?

Welcome to my People Tracker Page! This project is an AI person counter that utilizes a raspberry pi 3B as a host computer and individual Pi Zero Camera units that communicate over wifi to share data. It uses a raspberry pi 3B as a host computer and individual camera units that communicate over wifi. The units send real-time data of the number of people in a room to the host pi, which is a seperate unit. The camera units handle all image processing on board and simply pass the number of people in the room to the host, removing security concerns. Due to the setup, it is highly portable and infinitely scalable, as long as every unit is on the same wifi, of course! 

What is the AIY?

The Google AIY vision bonnet is an advanced device designed to be used with a raspberry pi zero, which is equipped with a mobile GPU for high-performance image processing and a slot for a raspberry pi camera. This device is geared towards hobbyists and enthusiasts who are interested in learning about image processing and building complex projects with raspberry pi firmware. The capabilities of this device are not limited, and it can be used to build a wide range of projects. The bottom of their project page showcases the diversity of projects that can be built with this device. Despite its compact size, the AIY offers a powerful solution for those looking to delve into the world of advanced image processing and building projects with a raspberry pi.

Setting Up the IoT Devices

I had started by flashing the firmware on both units, configuring wifi settings and enabling ssh access. Along the way, I encountered some problems, the most notable of which were an error code never-before-seen by the internet, and the default Raspberry Pi OS doesn't use the Google AIY vision bonnet. I also overcame some networking errors involving socketio and engineio. Read all about my process in a tutorial I wrote here.

The easy part: The AI

Creating a person tracker from scratch is not normally easy. Usually, it would involve collecting thousands of images of people, labeling them, and training an AI. Thankfully for us, Google’s AIY kit comes with a pre-trained and pre-built object detection model already installed. 

Unfortunately, the object detection model doesn't quite do what we want it to just yet. Out of the box, the model functions as a callable python script: you call the file, pass it an image file you wish to classify, and it outputs the number of objects detected, and can draw boxes around the objects in the picture if you so choose. 

What we need to do is call this function every timestep using the camera’s live input. Thankfully, we can borrow the structure of the face-tracker file and make a few obvious changes. Note the resolution change I put in - the object detector model uses a different resolution than the face detector does. Now, we simply need to add in the socketio function and broadcast it to the host Pi. Note that the ‘testAccept’ at the beginning of the sio.emit() call is actually a classification defined in the host code. The finished code is provided in my Google Drive.

Making the Case

Most engineers at my level have access to a 3D printer. I do not. However, I do have access to a box cutter and some leftover cardboard, which I can easily turn into a finished casing product, pictured here. The first thing I did was create holes for the on-board buttons and GIPO pin headers. After that, I punctured some small holes in the cardboard so the ends of the AIY pin headers could fit more comfortably into the cardboard. I also created some medium-sized holes for the plastic dowels between the vision bonnet and the Pi Zero. From there, it was a matter of making a few holes for the USB and HDMI mini slots and creating a resting spot for the camera. I made the box bend 90° properly by cutting halfway through the cardboard and bending against the cut. The camera slot is superglued onto the box, and designed to fit as snugly as possible. 

Final Results and Testing

The results of my final test can be seen in the graph on the left, which shows the number of people detected in my testing room over 40 seconds. Seeing as I was the only person in the room during the test, the graph naturally shows a range of 0 to 1. You may notice my person tracker dropped detection of me several times; this is due to me moving around and standing partially out of shot to test the applicable range of my person tracker. As such, the Single Person Drop Rate (SPDR) works out to 24.4%, which is relatively low, considering the limited hardware of the Raspberry Pi 0 and AIY vision bonnet. To improve on the SPDR rate, I would probably create a camera mount and use brighter lighting, due to the poor angle and visual fidelity of the testing room. I could also improve by retraining the person detection model, or using a more robust model such as YOLOv4. Regardless, this result is quite satisfactory; imagine this person tracker is being used in a room with 50 people. 24% of the time, one of those people is dropped. As the number of people increases, this SPDR rate becomes negligible. 

Watch the Project Demo!

See the CSV Output!

Galen Holland 2022 - The photos on this page were taken by me, using a mobile phone.