Like Python itself, GPIO Zero is an API with multiple programming paradigms. Users can begin with a simple approach, and have the opportunity to expand into using more advanced techniques to achieve more.
Relies upon PIL to parse the initial JPEG structure and then does its own TIFF/Exif parsing because PIL's isn't up to dealing with the "full" Exif structure; looks like it gives up after IFD0.
Only tested with the V1 camera module, but I expect it'll work with either model. There's lots of stuff in here which isn't as efficient as it could be and a fair bit of cruft, but it's only a demo :)
from picamera import PiCamera | |
from sense_hat import SenseHat | |
from PIL import Image | |
from signal import pause | |
class DisplayOutput(): | |
def __init__(self): | |
self.hat = SenseHat() | |
def write(self, buf): |
# WARNING: This probably won't work with current versions of the | |
# mmalobj layer; it was made while the layer was still being | |
# developed. | |
import io | |
import curses | |
import datetime as dt | |
from picamera import array, mmal, mmalobj as mo, PiCameraMMALError | |
from threading import Thread, Lock | |
from PIL import Image, ImageDraw, ImageFont |
This is a rough'n'ready experiment to see if it's feasible to detect shadowed modules on import. A shadowed module is one where a user has inadvertently named a module the same as a module on the standard search path (a common example in education is "turtle.py" and my own unfortunately named "picamera.py" :).
If this module is imported, it tweaks the standard import machinery to check for such shadowing
the first time a module is imported. If it finds any, it raises ShadowWarning
(which descends
from ImportWarning
) giving the path of the imported module, and the path of the first module
import re | |
from turtle import * | |
compass = {'r': 'd', 'd': 'l', 'l': 'u', 'u': 'r'} | |
angle = lambda a, b, r=0: r if a == b else angle(compass[a], b, r + 90) | |
cmds = ( | |
'd50u25r25u25d50R35l25u25r25d12l25R35D13u50R10d50R10u25r25d25l25R55' | |
'U50d50r15u25d25r15u50R10D25d25r25u25l25R35d25u25r25R10U25d50R35U25l25d25r25u50' | |
) | |
p = re.split(r'(\d+)', cmds) |
import re | |
from turtle import * | |
compass = {'r': 'd', 'd': 'l', 'l': 'u', 'u': 'r'} | |
angle = lambda a, b, r=0: r if a == b else angle(compass[a], b, r + 90) | |
letters = { | |
'H': 'u50d25r25u25d50', | |
'd': 'u25r25u25d50l25R25', | |
'e': 'u25r25d12l25D13r25', | |
'l': 'u50D50', |
#!/usr/bin/python3 | |
import pygame | |
from picamera import PiCamera | |
from pygame.locals import * | |
from sense_hat import SenseHat | |
from time import sleep | |
import sys | |
sys.path.append("..") | |
from mcp_utils import McpUtils | |
from norad import get_tle |
This is all extremely hacky so you'll probably need to play around with it to get it working. On a fresh Raspbian Jessie or Raspbian Stretch install, add all the build-deps we usually have on a piwheels build slave (see https://github.com/bennuttall/piwheels/blob/master/deploy_slave.sh and install all the -dev stuff and python libs, basically). Next, add a 1Gb swap file.
In the default "pi" user, make a "packaging" directory and stuff opencv-python-build
and
opencv-setup.py
under there. Make opencv-python-build
executable and edit the for-loops