Raspberry Pi, Ai Camera, SONY IMX500 Object Recognition. Halloween Project.
by gektor650 in Circuits > Raspberry Pi
879 Views, 10 Favorites, 0 Comments
Raspberry Pi, Ai Camera, SONY IMX500 Object Recognition. Halloween Project.
In a quiet suburban neighborhood, October had arrived, and the air buzzed with Halloween excitement. At the same time, a new Raspberry Pi AI camera came into my hands, and that means it's time to scare someone. People often fear AI because they believe it will take away jobs, but this time, it will help me create a new kind of fear.
Project Architecture
The concept is simple: a reaper that only comes to life when someone walks by, thanks to object detection powered by the new AI camera. Here's how the system works:
- An ESP32 and a relay are connected to the reaper, and the ESP32 is linked to a Wi-Fi network.
- The reaper is placed near the sidewalk.
- The AI camera and Raspberry Pi are hidden nearby, facing the sidewalk, and connected to the same Wi-Fi network.
- The AI detection runs continuously, and when the Raspberry Pi detects people, it sends a UDP broadcast message, 'BOO!'
- The ESP32 receives the message and activates the reaper, scaring passersby.
Raspberry PI & AI Camera (Sony IMX500) Setup
I used a Raspberry Pi with a standard Debian Bookworm system and some predefined Wi-Fi settings in Pi Imager.
To keep the AI module discreet, I designed an analog of a wildlife camera holder.
Then I put a Raspberry PI and an AI Camera inside and closed it with a cover.
The next step was to install the software. I have a repository that has all the required scripts:
https://github.com/Nerdy-Things/raspberry-pi-sony-imx500-halloween-project
For the Raspberry Pi, I needed to install the following dependencies. It is located in the /raspberry/install.sh
The script will work only if it runs inside the cloned repository. Otherwise, all models can be found here.
AI Camera Sony IMX500 Object Detection
After installation, I ran the recognition.py script, which is similar to the AI Camera example. But with the critical changes at the bottom:
The script uses an imx500_network_ssd_mobilenetv2_fpnlite_320x320_pp model and gets detection results from the AI Camera, saves an image to an SD card, and if a person is detected (result.category == 0), it sends a UDP broadcast message:
The remaining part was to place the hidden camera somewhere.
And run the script.
ESP32 & Relay
I want to keep my relay wireless, so I came up with the following schema.
Three AA batteries are connected to a voltage converter that stabilizes the output to 5V.
The converter is connected to the ESP32's 5V and ground pins, and the same wires are connected to the relay’s DC+ and DC-.
The rest was to replace the button with a relay and hang the reaper.