When the Useful Sensors Person Sensor came out a couple of years ago I was impressed by its tiny size and low cost. I was also intrigued by the Sensor 2.0 initiative for data privacy. The Person Sensor is performing face detection and recognition but biometric information is not available from the device. It is only used for detection on the sensor. The sensor only provides face bounding box location within the image frame and the detection confidence. It can also match a stored image that is also not accessible and provide additional information as to whether the pose of the head is facing the sensor (eye direction is not detected).
When testing use cases for image sensors I find it useful to be able to view the image that the sensor sees and correlate that to the detection metadata stream. Since the image data is not available from the sensor I thought that I would build a simple testbed using a RPi Zero W and RPi Camera mounted adjacent to the Person Sensor to capture the approximate image that it was seeing.
That was the genesis of the project recovered from my junk drawer. Unfortunately, it was one of those projects that started but never finished because other higher value projects came along.
Here are the pieces that came out of the "junk drawer" and an assembly showing how far I got.
Parts:
- RPi Zero W V1.1 with acrylic case
- RPi Camera V1.3
- Person Sensor V1.0
- 3D printed tripod mount for the assembly
Partially completed assembly (Person Sensor was not mounted). It was going to be mounted directly above the camera.
In the past two years, the Person Sensor has gone through a couple of revisions and the RPi Zero now has a much more capable 2 W version. I decided that I'd like to rebuild the project using the newer components and maybe throw in an RPi AI Camera for good measure. In the spirit of building from junk drawer components, I'll also build a variant using the original parts.
PCB DesignPCBs have gotten really inexpensive to design and fabricate and with quick fabrication times, so I thought that I would create a simple dedicated micro HAT. The HAT is very simple and just used for mechanical structure and to interface the I2C and power to the Person Sensor (the newer Person Sensors have header pins, but to use the original one I'll need a QWIIC adapter cable).
I did a quick and dirty PCB design in KiCad - 2 layers with only 3.3V, Gnd,,and I2C connections to the GPIO header. I had it fabricated by Seeed Studio Fusion. It cost $4.90 for the 10 board minimum and $13 shipping for a 10 day turnaround. $1.80 a board is much cheaper than anything I could have done myself (of course, I doubt that I'll ever use 10 boards). If I had more time I might have tried a more generic PCB - maybe UART, SPI, and I2C and QWIIC or Grove connectors.
I then 3D printed a tripod adapter to hold the RPi Zero/uHat assembly in a vertical orientation.
The finished assembly using the newest version of the components
- RPi Zero 2 W
- RPi AI Camera
- Person Sensor V2.0
A short video to show the operation of the testbed. The screen has 3 sections.
- Upper left is the RPi AI Camera output running mobilenet_ssd
- Lower left is a terminal showing the I2C output from the Person Sensor
- Right side is a webcam image of the testbed assembly
The Person Sensor has a green LED that lights to indicate that it has detected a face. It also outputs the following data via I2C:
- Number of faces detected
- Confidence of detected face
- Bounding box location of detected face
- Recognition confidence if the face id has been registered
- Face ID detected
- Whether the the face is looking at the sensor -"is_facing"
Example of the data printed to the terminal:
A few observations from the video. First, the Person Sensor is trained to detect a face rather than a person. The Person Sensor has a high confidence detection as long as I'm looking straight into the sensor. If I look up or to the left or right the sensor will go through a transition where it determines that I am not "facing" it and then will no longer detect my face. It does better when I am facing down but does drop out intermittently. It also will lose detection if I obscure my face using my hand. The RPi AI Camera using a dataset trained on "person" data always detects me as a person even when my face is obscured or not facing it.
I am using MQTT to send the detection information to a local MQTT server running on an RPi4. I'll use Node-Red to display the information on a dashboard.
The RPi Zero formats the Person Sensor data into a JSON object that is sent via MQTT message to the server.
Output from the MQTT input face_detection node:
The overall Node-Red flow:
Screen capture of the dashboard display:
Video showing showing the bounding box info updating:
The blue rectangle shows the position of the bounding box in the Person Sensor frame. Size of the bbox is a proxy for proximity.
Project VariantsSince I had extra PCBs I built two variants. Both are using non-AI RPi cameras so basically just act like a view finder for the Person Sensor.
The first variant uses the original version of the Person Sensor. This version did not break out the I2C or power to header pins and did not have mounting holes. I 3D printed a holder for the sensor and added a QWIIC pigtail cable to interface to the PCB. This sensor version also had the "up" orientation with the QWIIC connector on top. The newest sensor has the orientation with the connector on the bottom so I have flipped the PCB 180 degrees when attaching to the tripod mount. This variant uses the RPi V1.3 camera and the RPi Zero W..
Screencap of Person Sensor Testbed running with the original junk drawer parts:
The second variant uses the new Person Sensor and the RPi V2.1 camera and the RPi Zero W.
I'm using longer camera cables on the variants because I don't have any more of the short ones. I only use a heatsink on the processor with the Zero 2 W and not the Zero W variants. The I2C bus used on the Zero W is /dev/i2c-0 and on the Zero 2 W it is /dev/i2c-1 so that also requires a software change.
Comments
Please log in or sign up to comment.