Halloween is coming, and what better way to celebrate the season than by using machine learning and a Raspberry pie to accomplish something scary! This year I built a mannequin head that uses person detection and a simple servo motor to sense when a person walks by and turns their head to follow them. I use a simple styrofoam mannequin head with colorful eyes from the dollar store, but you can dress it up to suit your home theme or use a completely different type of head or object. As long as you can use a servo to rotate it, the result is the same.
This project will not require any machine learning training and is more or less plug and play just in time for the season. Here’s how to build it.
What you will need for this project
How to build a Halloween mannequin head that follows a person for Halloween
Before you start, set up your Raspberry Pi. If you haven’t already, check out our article on how to install a Raspberry Pi for the first time or how to make a Raspberry Pi headless installation (without keyboard and screen). For this project, we recommend a Raspberry Pi headless installation.
1. Install git. We’ll need it to download the code from GitHub.
sudo apt-get update sudo apt-get -y install git
2. Clone the repository to your home directory. This will ensure that we have all the code and audio files we need to run the project.
cd ~/ git clone https://github.com/rydercalmdown/halloween_mannequin_head.git
3. Run the command “make install” to install all the dependencies of the project. This script will take care of installing the lower level dependencies, as well as the Python libraries that you need for the project to run. It should take around 10-15 minutes on a Raspberry Pi 4, as it takes some time to install the libraries and machine learning models.
cd ~/halloween_mannequin_head/ make install
4. Choose your camera; if you are using a Wyze V2 camera, skip to step 6. If you are using a Raspberry Pi camera, skip to step 5. Both will work, but the advantage of the Wyze camera is the ability to mount it in a another place it away from your Pi (and the mannequin head).
5. Connect your Raspberry Pi camera directly to the Raspberry Pi and test it with the following command. Do not set the STREAM_URI environment variable, it will use the Pi camera by default. Go to step 8.
sudo raspistill -o test.jpeg
6. Flash custom RTSP firmware on your Wyze camera using these instructions. This will allow us to access the wireless camera feed with the Raspberry Pi. It will only work with a Wyze V2 camera.
7. Get the value of the RTSP URL from your Wyze app, and edit the STREAM_URI variable in the Makefile to point the Raspberry Pi at your camera. You can find the RTSP URL in the “Advanced Settings” section of your Wyze app on your phone.
nano Makefile # Only edit this if you’re using a RTSP camera; leave blank if you’re using a Pi camera STREAM_URI=rtsp://username:[email protected]_ip_address/live
8. Hot glue your servo motor on a wooden base, or directly where you intend to mount the mannequin head. I drilled a small piece of wood to use as a base and installed the motor inside.
9. Hot Glue the servo bracket with the motor to the base of the dummy head. I used a small piece of wood to strengthen the connection, but depending on yours, you might not need it. Make sure the bracket can still connect to the motor.
10. Using jumper cables attach the 5V and ground pins of the servo motor to pins 4 and 6 of the Raspberry Pi respectively.
11. Using a jumper cable, Attach the servo motor data pin to board pin # 3 on the Raspberry Pi. This pin allows the control of the servo motor by the Pi directly.
12. Using the support, connect the mannequin head to rest on the servo motor and mount device and camera at the desired location.
13. Use the make run command to test the system. Enter the camera frame and move left to right to rotate the servo.
14. Adjust the mannequin head on the servo by lifting and re-centering it to calibrate it so that it follows you correctly.
15. Buy your thing or treat and get it ready for Halloween.