Person Detector -- tracking a face. Possible?

I have two TFT displays that show eyeballs, with blink and iris dilation and other eye-like behavior. From Adafruit.

A friend sent me the link to the Person Detector and I bought it thinking I could track a face from left to right or vide versa. However, if the face is too close, I believe the bounding box takes up almost the entire image area. So if the person moves from left to right in front of the sensor, the bounding box stays large and doesn’t have any room to actually track the movement of the person.

The sensor is connected to an ESP32-S2 Feather via the QwIIC connector and works fine out of the box. The ESP32 then converts the LEFT and TOP values to a voltage between 0 and 3.3V and send this to the joystick input on a Raspberry Pi 3B fitted with a bonnet for the TFT eyes (also from Adafruit). If I connect an actual joystick to the bonnet, the eyes do move left-right and uop and down. I’m just simulating the joystick’s values from the ESP32. Seems logical.

Perhaps this sensor is not the correct one to try to tracks faces with?

I’m still in the experimenting-with-it phase, so there is a good chance my code has a flaw. More debugging is necessary and I need to scrutinize more carefully the debug output from the sensor. During initial testing, the LEFT value actually did change as I moved across the sensor, so that’s why I think I may have a coding issue. However, perhaps this sensor is not the optimal choice to track the movement of faces.

Oh… this is whole project is about face-following eyes to be placed in either a pumpkin or a skull for Hallowe’en. I have some time to get this working, but being slightly autistic, I need instant gratification. Now.

I say, “Let’s investigate this further”. I haven’t worked with Pi cameras as I’m kind of Arduino-centric. But…

I had thought that a 2D camera approach might be better. I think you just confirmed that. Plus, I’ve been wanting to get a small camera anyway. Thanks for the tip.

Here’s a walkthrough for setting up OpenCV and getting facial detection working on a pi:

https://www.circuitbasics.com/introduct … pberry-pi/

The person detector doesn’t detect faces, it only detects a warm human sized blob and calls that a person. If a small bear were to walk by, it would be detected as a human. (There’s no built-in intelligence that can distinguish between a bag of warm meat and a person)

If you want to detect a face you will want OpenCV like others have suggested.

To all of you that suggested openCV, yes, this would be the way to go; however… I have a CPU-intensive program running that controls the TFT eyes. OpenCV, I think, will require a lot of CPU and memory as well, possible impacting the eye drawing and movement. To this end, I off-loaded the Person Detector to a satellite ESP32-S2 mostly because I need 2 DACs to control the X and Y position of the eyes. I’m simulating a joystick because the bonnet that the eyes attach to have analog inputs for a joystick. As I stated in the original post, this seems the most logical way to incorporate the person detector.

On the Useful Sensors site, there are four projects showcased where the PD sensor was satisfactorily used to track bodies and faces to control servos and TFT eyeballs. I think it can be done with the PD sensor, but it’ll require some due diligence to figure out exactly how.

I mused last night about having another Pi running openCV and a 2D camera and passing the voltages based on the detected object’s position back to the Pi controlling the eyes. However, there are no on-board DACs on a Pi, so I’d need a DAC board (as well as another Pi. I have a Pi 5 coming but I’d rather not use it for this purpose). And I was going to follow this route until I saw the projects on the Useful Sensors’ site. That discovery made me think I can indeed use the PD sensor for what I want to do.

So, yes, I’m open to all sorts of solutions; I just need to fully vet the PD projects and try to determine how those developers used that sensor to track motion. And then I need to translate the Python code to C++ for the ESP32.

Definitely a work in progress and thanks to all that have replied.

My mistake, when you said person detector I though you were referring to the [SparkFun Human Presence Sensor Breakout - AK9753.

The [Person Sensor by Useful Sensors looks more capable and might be able to do what you’re looking for but may not have the resolution I think you’re after. At $10, if it doesn’t have the resolution you’re after you could use several together.

Good luck with your project!](https://www.sparkfun.com/products/21231)](https://www.sparkfun.com/products/14349)