Using AI human detection to trigger a Bubble machine

Mark_M

Annoying Elf
Generous elf
Joined
Dec 30, 2018
Messages
912
Location
Christmas Light world
Don't want to read? Watch the video here:

View: https://www.youtube.com/watch?v=v7oSQ6_6A9I



In 2023, Bill Porter did a presentation about using artificial intelligence to trigger a snow machine.

He achieved this with the software Blue Iris, this is a camera recording software and enables the use of plugins such as AI object detection.
Upon detecting a person, Blue Iris sent an MQTT command to Home Assistant.
Home Assistant is home automation software which can link multiple devices together, in his example it linked an MQTT message to switching the snow machine. Presumably through a relay, smart plug socket.

I want to create my own version of this, but without the complexity of Blue Iris object detection plugins and without having to link to Home Assistant. I did this by using a security camera which already has human object detection and then activating a relay output built into the camera.

flow_chart.PNG

Before I go any further, yes you can do this in multiple ways - My goal of this project is to be simple as possible for anyone to recreate.



For this project I'm using a Dahua security camera with human detection built in.
On the fly-lead of the security camera is 4 wires for the alarm input and output. The relay output wires is what will be using for this project.
Some security camera recorder units also have a relay output built-in which you could use.
Slide3.PNG

My security cameras built in relay can handle 12v at 300mA. I'm going to use a PC Trickle Saver relay which powers on 5v to switch 230v to my Bubble machine.
DO NOT CONNECT MAINS AC VOLTAGE TO A CAMERA OR A RECORDER UNIT RELAY TERMINALS, this is highly dangerous and could result in someone being electrocuted.

In the interest of safety and ease for anyone who wants to recreate this. I'm using a Trickle Star (brand) PC Saver (Model) which can switch 230 volts on and off with a 5 Volt input to its relay. Other safe relays with an external control can be found online like the Power Switch Tail.

1706159440000.png
This device is the PC saver by the company Trickle Star. The purpose of this product was to turn off any peripherals connected to its output when the USB ports stopped receiving 5v from your computer, assuming that your desktop computer had been powered off. I bought this device for $1.50 off a local auction site.

Looking at the inside of this Trickle Star PC saver; I can see it is literally just a 5V relay coil and it's switching 230V AC.
1706159590429.png
Important to note is this relay is polarised. This means that there's a positive and negative terminal. This is because a fly-back diode is wired in series to the coil. If you're going to use your own relay, make sure it also has a fly back diode.



Here's how I wired the relay of the camera to the PC Saver relay. I used a 5V power supply to power the Trickle Star PC Saver relay coil and connected this in series to the cameras relay.

Slide4.PNG


Post #2 is camera configuration.
 
Last edited:

Mark_M

Annoying Elf
Generous elf
Joined
Dec 30, 2018
Messages
912
Location
Christmas Light world
Now logging into the web interface of this camera.

This Dahua camera needs to have IVS enabled.

1706162375360.png

There's a few options to configure IVS rules with this camera. I could do a line cross rule or an intrusion rule. Line cross rule is when someone crosses a line and intrusion rule is when someone enters into a box. I chose to do a line crossing rule.
1706162403126.png

The rule gives us the number of functions we can do.
I left sensitivity on default and the direction for both. Enable target so it only trigger on a human.

Time plan was also set to full time, you could change this to be a scheduled time such as 8:00 PM till 10:00 PM on weekends.
Under event linkage, I removed these snapshot option and added the option for alarm-out port. This is the relay on the camera. I left it at the default of 10 seconds.

Idea: Having a schedule means that you could activate speakers only when your lights are turned on and when a person is outside.


I drew a line on screen. This is the line when a person crosses it, it will trigger the event.
There is also options for a minimum size and maximum size target filter. Example is if you are having issues with people far away triggering the event.

1706162448075.png

Now what's the AI detection rule is enabled; If a person crosses this line, it will trigger the relay from camera which will trigger the relay switching 230v AC to my bubble machine.

A quick test in the garage and this works!
1706162470795.png

Make sure to mount your camera high and out of the way of bubbles or the foam from a snow machine or smoke my fog machine. AI object detection is best when the camera does not have any obstructions.
1706162490451.png
 
Last edited:

Mark_M

Annoying Elf
Generous elf
Joined
Dec 30, 2018
Messages
912
Location
Christmas Light world
So, what if you wanted to activate a fog machine?
A fog machine needs to be plugged into power all the time in order to keep its heater element hot.
You could trigger the fog machine by hacking the remote control of it, or if it has DMX user way to send a DMX command to it.


This could be done with a cheap Arduino module style relay wired across the button of the remote control for the fog machine. This would likely be wiring mains voltage AC which is dangerous.
Or you could use the relay output on the camera to switch ground to a GPIO pin on a Raspberry Pi running FPP. Then FPP commands the fog machine over DMX.


You can already see where this is going. There are so many possibilities what you could activate based on the camera. I could use this to stop the show and play a sequence to remind parents to keep their kids out of the lights.


Other examples are;
Controlling Halloween Animations, Christmas Animations, snow machines, bubble machines, fog machines, speakers, interactivity functions and soo much more!
 

Mark_M

Annoying Elf
Generous elf
Joined
Dec 30, 2018
Messages
912
Location
Christmas Light world
There are many ways you could achieve this functionality. Using a camera with human attention built-in and a physical relay, is in my opinion is the easiest way that someone could achieve this functionality.

But you could use other software such as Blue Iris or Frigate to give human detection to an ordinary security camera.


Whatever suits you!


Thanks for reading through this post and the video linked.
Please leave any questions and comments, or even show your implementation of AI object detection!
 
Top