DIY Harry Potter Moving Portrait Project

4,573

42

7

Published

Introduction: DIY Harry Potter Moving Portrait Project

The following is an instructable intended for pure-blood wizards only. If you are not a pure-blood, Slytherin specifically, you have been warned of the inevitable failure and defeat you will encounter as a squib, muggle, Hufflepuff, or mudblood.

Step 1: Obtain Materials

Utilize any means necessary to obtain these materials. Feel free to Wingardium Leviosa something out of a muggle store when their backs are turned and they'll be none the wiser.

Step 2: Prep SD Card and Load Raspbian, and FBI Plugin

This is one of the most important steps and an essential skill that is quite applicable in the Dark Arts. If you can format an SD card and load Raspbian, you’re about halfway to breeding a dementor.

  • Plug the SD card into computer and follow instructions to format SD card as...
    • FAT if 8gb
    • exFAT32 if 32gb
  • Load Raspbian onto the Pi
  • Downloading FBI plugin
    • Open terminal and install fbi to display images
<p>sudo apt-get install fbi</p>

Step 3: Take Video

The only thing that should be dark for this step is the Dark Lord. Make sure you have proper lighting. Above all, look good, deadpan serious, and menacing.

  • Take a video of what you would like to have moving in the portrait
    • Be sure to start and stop in the exact same position (Ideas include having a scenic portrait and someone walks in and out of frame, start sitting on a chair with hands folded and return to the exact same position)
  • Before you start movement, make sure to capture a still picture of original image, and set the size of image and video based on monitor dimensions
  • Download both the picture and video files onto Raspberry Pi and place your video, in the "Video" folder, and your photo, in the "Picture" folder

Step 4: Prepare Old Monitor

First, go to your monitor collection and select the one you like most. Sometimes local schools or businesses will surplus their old stock. Next, you will need to disassemble the monitor so that it is void of its back cover. This step varies depending on the monitor you have, but it is so simple a muggle could do it. Just kidding. Muggles are worthless and incapable of anything at all.

Step 5: Connecting Sensor

  • Insert the three prongs of the sensor into breadboard
  • Connect wires
    • The first cable goes from the 5v pin (the magenta cable), and connects to VCC pin on sensor
    • The second cable goes from GND pin (the white cable) and connect to GND pin on sensor
    • The third cable goes from GPIO pin 4, port 7 (gray cable) and connect to OUT pin on sensor

*The wires can go in any of the lettered ports as long they are in the same row. For example, the red cable is in 11c going from GPIO pin 4, to OUT which we put in 24b. The first one could go in 11a, 11b, 11c, or 11d or 11e. You just have to make sure to connect it to GPIO pin 4 and the OUT port on the sensor.

Step 6: Inserting Code

This code is NOT to be shared with any who do not possess the Dark Mark. Death Eaters have worked relentlessly on developing this and do not want any worthless muggle-borns or blood traitors laying their filthy little hands on it.

  • Open Thonny Python IDE from the programing menu and paste the code from file attached
#part 1 of code, motion detector code<br>#!/usr/bin/python<br>import RPi.GPIO as GPIO
import time
import os</p><p>class detector(object):
        def __init__(self, sensor):
                self.callBacks = []
                self.sensor = sensor
                self.currState = False
                self.prevState = False</p><p>                GPIO.setmode(GPIO.BOARD)
                GPIO.setup(self.sensor, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)</p><p>        def read(self):
                self.prevState = self.currState
                self.currState = GPIO.input(self.sensor)</p><p>        def printState(self):
                print( "GPIO pin {0} is {1}".format(self.sensor, "HIGH" if self.currState else "LOW"))</p><p>        def subscribe(self, callBack):
                self.callBacks.append(callBack)</p><p>        def callBack(self, state):
                for fn in self.callBacks:
                        fn(state)</p><p>        def start(self):
                try:
                        self.read()
                        self.printState()
                        while True:
                                 self.read()
                                 if self.currState != self.prevState:
                                         self.printState()
                                         self.callBack(self.currState)
                                 time.sleep(.1)</p><p>                except (KeyboardInterrupt, SystemExit):
	#Since fbi doesn't restore the console correctly when the application is exited we do a little clean up.
                    os.system('stty sane')</p><p>#part 2 of code, photo and video                 
#!/usr/bin/python
import subprocess as sp
import sys</p><p>video = ["omxplayer", "filename", "-o", "both", "--win", "0 0 1680 1050", "--aspect-mode", "fill", "--no-osd", "--orientation" ,"0","--vol", "-600"]
videoFile = "/home/pi/Videos/1680x1050video.mp4"
print(videoFile)</p><p>def onMotion(currState):
    if currState:
        video[1] = videoFile
        subVideo = sp.Popen(video)
        while subVideo.poll() is None:
            time.sleep(.1)</p><p>def showImage():
    os.system("sudo fbi -T 1 -d /dev/fb0 -noverbose -once /home/pi/Pictures/1680x1050picture.jpg")</p><p>showImage()
objDetect = detector(7)
objDetect.subscribe(onMotion)
objDetect.start()
os.system("sudo killall -9 fbi")
  • Save file
    • We saved ours to a folder named genlab and named it Masterpiece.py
  • Test Code
    • Open terminal and open file.
cd genlab
Python Masterpiece.py

*This is how the code actually works.

Our code displays an idle image on a monitor until the motion sensor detects movement and activating a video file and returns to the idle image’s initial still position. We were able to find a open source code used by Dominick Morino in his Possessed Portrait DIY Project, and simplified it for our project’s. We split the portrait code into two sections: the motion sensor commands and then the photo/video commands. For the motion sensor, we imported the initial libraries for Raspberry Pi and the GPIO board. You don’t need to change anything on the first part of sensor code. The second part of the code imports further libraries to allow the video commands to be contingent upon the sensor code in part 1.

Step 7: Personal Modifications

Make sure to insert the proper modifications. Get more customized than a wand from Ollivander’s here.

  • On line 54 aspect ratio. To change the orientation from landscape to portrait change the 0, to 90. For the actual ratio of your monitor change 1680 1050 portion
video = ["omxplayer", "filename", "-o", "both", "--win", "<strong>0 0 1680 1050</strong>", "--aspect-mode", "fill", "--no-osd", "--orientation"]
  • On line 55 change video name from 1680x1050video.mp4 to your file name
videoFile = "/home/pi/Videos/<strong>1680x1050video.mp4</strong>"
  • On line 67 change picture name from 1680x1050picture.jpg to your file name
os.system("sudo fbi -T 1 -d /dev/fb0 -noverbose -once /home/pi/Pictures/1680x1050picture.jpg")
  • On line 71, the sensor is connected to GPIO port 4, which is port 7 on the breakout board. If you want to move the sensor make sure you change it to the correct number
objDetect = detector(<strong>7</strong>)

Once you are done with the code save your file, take note of where you saved the file Open the terminal cd Press enter Photo will appear Block motion sensor Video will begin Esc, exits out of project

Step 8: Finishing Touches

Soldering must be done here. Feel free to use the Incendio charm in order to expedite the heating process for the soldering iron.

  • Once you have a working moving portrait, solder each wire to the sensor
  • Arrange the pi, and motion sensor on the back of the monitor and fasten with any with an adhesive of your choice (velcro, gorilla glue, duct tape etc.)

Step 9: The Frame

First, a panel of wood was cut and secured to the back of our monitor using the mounting hardware already built into the screen. We just found screws the same size and drilled the piece of wood into the back of the monitor. If your monitor does not have a means of fastening it to a panel of wood, an other option would be to create a custom-fit casing to support it.

We then repurposed a frame some bloke from Hogsmeade was just going to toss out. We sized it to our monitor and reinforced it with strips of MDF. This frame was glued to the wooden panel attached to the monitor using epoxy, but a simply fixing charm could work as well.

Share

    Recommendations

    • Casting Contest

      Casting Contest
    • Woodworking Contest

      Woodworking Contest
    • Microcontroller Contest

      Microcontroller Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    7 Comments

    This is really cool! I'm a big Harry Potter fan and this might just be my next project...Great job :)

    Amazing project! Is it possible to do with an arduino instead? Just curoius.

    1 reply

    There are a couple things with arduino. The first thing is that arduino's generally aren't powerful enough to play a video at 60 FPS. You would also have to code in C++ instead of python.

    Awesome!!

    This made me want to make a frame that play videos of my son in Google Photo.

    <3 the creativity and homage to Harry Potter

    This is incredible! I'll be making my own soon.

    This is awesome! I have wanted to make one of these ever since I saw the Harry Potter movies.