How to make a dark shadow film series using the Raspberry Pi 3 with Python 3
In my previous post, I demonstrated how to make your own dark shadow films using the RPi 3 with an application called Raspberry Pi Cinema.
Now that the Raspberry PI 3 is fully ready for filming, you can make dark shadows using a Python script and a Python application.
This post will focus on making dark shadows from a single image using a Raspberry Pi.
If you are using a second Raspberry Pi, then you will need to follow the steps in the second post.
Here’s the script and application: $ sudo python3 python3-raspbian.configure $ sudo apt-get update $ sudo python python3.4.1 $ sudo pip install raspi-pi-cinema If you get an error that says: You cannot install the following packages: python3,rpi-pi,python3-gobject,python-cairo-core,python2.7,python python-gi-core $ sudo yum install python3 and sudo yump install rpi-pip python3 is the python-based Python package for Raspberry Pi which comes with all of the Python packages and the Raspbian distribution.
This will install the Python 3 runtime.
The script I used for this article is called dark_shadows.py.
This script installs and runs a Python 3 script called dark.py to convert the dark shadows into an RGB image.
The script takes the original dark image, converts it to an RGB pixel format, and then uses that to convert an RGB frame to a RGB image (using gi.py).
I chose this script because it’s pretty easy to use, and has a very simple interface.
To run the script, first add the script to your home directory.
sudo chmod +x dark_seasons.py Then run the command dark.sh: python3 dark.sln After the script is run, the dark_images.py file is located at C:\Program Files\Raspberry Pi\images\images.
The file is called images.py and has the following content: import rpi.image import pygame.image.
BufferedImage import pyglet import pycairo import time import json import csv from collections import namedtuple import json_archive from os import exit def run(argv): image = raw_input(‘What image do you want to convert?’) r = rawImage(image) frame = json.loads(json.dumps(image)) frame.decode(‘RGB’) return frame,image return None def convert_frame(image): for pixel in image: # convert the frame to an RGBA pixel for y in range(4): # convert to RGB for x in range(-2,4): frame[y][x] = (x + 4) / 4 if convert_image(frame,image): return frame return None The script creates an image named images.png, converts that image to a RGBA image, and returns the result as a Python object.
I use this Python object to convert a Python frame to the RGB pixel image.
In the example above, I’m using the Python image.py package for Python 3 and pygltest for Python 2.7.
When the script runs, you will see a new window with a dark_snowflake.png image.
If you have a second raspberry pi, you should see the dark.png file there.
Now that the script has finished converting the image, you need to convert that image into a RGB frame.
# convert the image to an RGB frame import pyimages import pyimage.image as png r = pyimages.RGBA() png.convert(r, png) return png