Living Portrait Scare for Halloween Using a Raspberry Pi, PIR and Python

19,799

211

90

Introduction: Living Portrait Scare for Halloween Using a Raspberry Pi, PIR and Python

Lets make a living portrait effect for Halloween, and scare some people.The goal is to have the portrait remain still until the motion sensor is triggered and to do this without a blank space between videos, the scare or the reset of the image. Many of the triggerable media players aren’t seamless and for those that are its quite expensive.The cheaper ones results in a black screen in between scares or even between scenes, which totally ruin the effect.Here we will use a raspberry pi and python3, and by the end of this you too can have a wonderful Halloween prop, and scare anyone that comes close.

Parts needed:

  • Raspberry pi 2|3: $35.00
  • 5v PIR (Passive InfraRed) sensor: $5.00
  • I got mine from amazon for around 8.00 (now 11.00) but it comes with 5 from Amazon
  • Unliving portrait video: $8.00 AtmosFX
  • TV|Monitor: you have this laying around
  • Wood or old frame to cover monitor


Software Needed:

  • Python: pre-installed on Raspbian
  • Omxplayer: pre-installed on Raspbian
  • Omxplayer-wrapper library

Step 1: Software and Connections

I’m not going to go into how to setup a pi, there are plenty of documents around that, but if you need it here is the documentation on how to install Raspbian. I recommend using SSH and setting up wifi to make it easy to test and start the script. How to setup SSH on windows and Raspbian here.

Now we need to install Omxplayer-wrapper and grab a script from my github.

Open a terminal in Raspbian and enter

  • sudo python3 -m pip install omxplayer-wrapper
    • this should install all the requirements and should be all you need to set it up
  • Grab my portrait player script from My github page or attached to this instructable.
  • Copy your living portrait video to the pi somewhere.
  • Once this is done, omxplayer-wrapper is installed, and all the files are ready turn off the pi and continue on.
  • To set up the PIR to work with the PI you need to connect the Sensor.
    • PIR VCC to 5v(pin2)
    • PIR Out to GPIO4(pin7)
    • PIR GND to GND(pin6).


Your PIR might be different in layout please ensure its correct. Also turn all the potentiometers counter clockwise which should be all the way down, you can adjust sensitivity later if needed. If you need a narrow field of view from the sensor I recommend removing the plastic cover from the PIR.

Step 2: Testing

With this hooked up start up the pi and navigate to the folder where the living_portrait.py script is, depending on your settings you may need to adjust the screen width or screen height. In the living_portrait.py script change the swidth and slength variables to match your monitor. Mine was 1440x900.

To start the effect run:

  • python3 living_portrait.py filename
  • for example:
    • python3 living_portrait.py UP_Gent_LivingNightmare_TV_V.mp4

It is important to note that what happens in this effect is the player starts the video and then pauses it immediately before the scare happens. Make sure you pick a video that when un-paused it will produce the effect you want.

Lastly, we need to frame our monitor, you can either use an old frame that fits or you can make your own for pretty cheap. Buy some molding from Home Depot cut it on 45-degree angles and either nail or staple it together. I also mounted to L-brackets to my frame so I can hang it on the monitor. For a final touch I drilled a hole for the PIR sensor, but this isn't necessary and sometimes takes some trial and error to make the trigger work to ones desire.

Step 3: The Result

Simple and great effect. Check out the video and go scare someone! if you liked this please vote for me in the halloween contest.

Halloween Contest 2017

Participated in the
Halloween Contest 2017

5 People Made This Project!

Recommendations

  • Puzzles Speed Challenge

    Puzzles Speed Challenge
  • Secret Compartment Challenge

    Secret Compartment Challenge
  • Lighting Challenge

    Lighting Challenge

90 Discussions

0
charlesbucher2007
charlesbucher2007

Question 3 months ago

How could I modify this to be triggered by a relay?

0
stagge99
stagge99

Tip 1 year ago

If you use USB speakers use '-o', 'alsa:hw:1,0' arguments.
player = OMXPlayer(VIDEO_PATH, args=['-o', 'alsa:hw:1,0', '--no-osd', '--loop', '--win', '0 0 {0} {1}'.format(slength, swidth)])

0
cesarcamilion2
cesarcamilion2

Reply 9 months ago

for ayi google voice kit just put alsa without 1,0' like this

player = OMXPlayer(VIDEO_PATH, args=['-o', 'alsa', '--no-osd', '--loop', '--win', '0 0 {0} {1}'.format(slength, swidth)])

work fine

0
Greenadder03
Greenadder03

9 months ago on Step 3

This is a cool project thank you for sharing.

I am not able to get my portrait to trigger, it just gets stuck, does anybody know how I can fix this?

0
Greenadder03
Greenadder03

Reply 9 months ago

I fixed it, I found out that in the library of scare animations there is a standstill image on a loop and that happen to be the one I selected first.

0
romeo294
romeo294

Question 9 months ago

Probably a noob question, getting a 'list index out of range' when try and run python. Any ideas?

0
romeo294
romeo294

Answer 9 months ago

Scratch that... I'm deff a noob. Think I got it.

0
thesunny73
thesunny73

Question 9 months ago

Hi, Thanks again for this wonderful instructable. I had it up and running last year but now I want to set it up again but it is not working any more. I did nothing with the raspberry during last year so nothing changed.
If i try to let it run via the terminal it goes to quick to see wat is happening. I hope someone can help me. It is almost halloween.

Greetings Marcel

0
thesunny73
thesunny73

Answer 9 months ago

It is fixed. Not realy how I like it but it is working. Tree paintings simultaneously.

0
cosmodk32
cosmodk32

10 months ago

Great Project, got it working pretty easy. I made a frame out of a piece of lumber, and added a "feature" on top of the frame for the PIR sensor - But i really could use some Python help, i want it only to react to PIR input once every 10 mins - to give my co-workers a chance to breathe between scares. i tried the sleep(10) command, however i am not sure where to put it in the script to make it work like i intend to. Any suggestions would be greatly appreciated. and THANKS for this project.

IMG_9697.JPGIMG_4665.jpgIMG_6737.jpg
0
mcneilp
mcneilp

Reply 10 months ago

Try putting it right after the pause command.

0
mcneilp
mcneilp

Reply 10 months ago

How long does yours run without getting "stuck"? I am wondering if I need to rebuild mine as it seems to crash or get stuck almost every day.

0
cosmodk32
cosmodk32

Reply 10 months ago

Hi thanks for the great feedback. I’ve been running it for 8 hours at work today without crashes, though I need some small adjustments to sensitivity :)

1
mcneilp
mcneilp

Reply 10 months ago

Oh, and your frame is gorgeous. Very nice work!

0
mcneilp
mcneilp

10 months ago

This project is great, and your instructions are simple and work. So nice. It does seem like it "hangs" (ironic choice of words). It will stop responding to motion and just show the first frame of a video. I reboot and it works for a while, but i have to reboot again. It fails within 1-2 hours typically. Any thoughts on why this might happen? or how I might go about resolving it?

0
marcusmq1
marcusmq1

10 months ago

Excellent project and works well! I am now working on the Pi4 and would like to be able to control and run 2 independent video's with the triggers across two screens. Not an expert on python and I tweaked the code. I can get both video's to display, but only one is triggered (works), the other Omxplayer instance keeps looping. Any help most welcome!

0
JuliusM32
JuliusM32

1 year ago

This is great, but when you buy the videos, there's a buffer video meant to play on a continuous loop until the sensor is activated. Then it will switch to play one of the 2 videos that come with the download (eyes-on-you or scare/nightmare)... I seems like the script could perform this process, but I'm extremely new to coding and don't know how to do it.
Anyone here capable of writing something similar?

0
scifideity
scifideity

Question 1 year ago

How would I trigger this from an Arduino running Octobanger (buttonbanger.com)? I've got it working fine with the PIR directly connected to the Pi but would like to insert the Arduino in the path so it can handle playing an ambient attract mp3. Then, when the PIR on the Arduino triggers it can let the Pi know to play the video while it handles signals to the relays to control the Monster in a Box lit solenoid, lights, and fog. I've tried hooking it up with the Arduino/Octobanger using Trigger Low out to the Pi on the same pin as the PIR but the video loads up and immediately starts to play and loops.

0
DennisBiker48
DennisBiker48

1 year ago

My scare video takes 12 seconds. If the PIR sensor detects a
motion, sometimes the video don't start at 0. Instead it jumps to the
8th second. So it stucks.

Another thing: It would be great if the video plays just one time. Sometimes the video plays for 3 or 4 times and then stop.

Please can anyone help me?