Face Tracking Phone Stand

Project Objective & Background

After moving away from home, I found myself frequently making Facetime calls while cooking, which I would have to pause every few moments to readjust the camera position. I wanted to create something that could keep me in focus no matter where I was standing in the kitchen. 

Mechanical + Electrical Design

Left: Version 1 of the Phone Holder in red. Had too mange sharp corners and the camera holder portion was too flimsy. 

Fully assembled device with electronics cover

Since I already had a Raspberry Pi 4B, I purchased the RPi Camera Module for the vision system and designed a case to protect the camera and allow it to blend into the assembly. I also needed a power supply strong enough to power both motors which could draw up to 3A each, and then the Pi which needed another 3A. 

Back view with electronics. Red attachment is a counterweight holding two 1-inch diameter steel spheres to assist with tilt motion. 

Camera board protection casing

Python Machine Learning Code

Using OpenCV2, a Python vision library, I used a pre-trained face model and the Cascade classifiers to set up face tracking. I also set some limits on the servo movement within the code to prevent the servos from running into the hardware. By reading the location of the face in pixels, and then subtracting the number of pixels away from the center incrementally, I can always make sure the face is centered in the frame by moving the motors to that position. I also added a feature I call "Sentry Mode" where the motors would start panning the motors around to find a face if none was detected in a certain time interval, but I decided it wasn't as useful for my application. View my code on Github here!

The machine learning algorithm is fairly resource-intensive on the Raspberry Pi, so I had to set limits and tweak the parameters of the searching function to make sure the FPS remained stable enough to produce smooth servo movement. 

Videos

Phone stand in action with no phone weight

This is the stand in full use as seen from the FaceTime perspective

Challenges

Problem: Face recognition was slow to respond

Solution: Reduced camera pixel output dimensions, tweaked classifier inputs, and optimized code to increase Raspberry Pi performance to run the processing-intensive machine learning code

Problem: Servo motors struggled to move the phone upwards due to the weight of the phone + assembly

Solution: Designed a counterweight attachment that would counteract the torque produced from the weight of the phone