This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a simple gui for creating stop motion animations using the Pi camera | |
# martin@ohanlonweb.com | |
# stuffaboutcode.com | |
# Instructions: | |
# - Connect a camera module | |
# - Enable the camera (Menu > Preferences > Raspberry Pi Configuration, Interfaces, Camera) | |
# - Install the relevant modules, open a terminal (Menu > Accessories > Terminal) and run: | |
# - sudo pip3 install guizero | |
# - sudo pip3 install imageio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from picamera import PiCamera, PiCameraCircularIO, PiVideoFrameType | |
from picamera.array import PiRGBArray | |
from time import sleep | |
import io | |
import cv2 | |
def diff_image(t0, t1, t2): | |
d1 = cv2.absdiff(t2, t1) | |
d2 = cv2.absdiff(t1, t0) | |
return cv2.bitwise_and(d1, d2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from guizero import App, Text, Drawing, Combo, Box, Slider, PushButton | |
def start(event): | |
painting.start_event = event | |
def draw(event): | |
painting.line( | |
painting.start_event.x, painting.start_event.y, | |
event.x, event.y, | |
color=color_picker.value, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
An adaptation of Adafruit's thermal camera example which | |
uses the sense hat to display temperatures. | |
Martin O'Hanlon | |
@martinohanlon | |
stuffaboutco.de | |
""" | |
from sense_hat import SenseHat | |
from Adafruit_AMG88xx import Adafruit_AMG88xx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A utility for padding image files. | |
""" | |
from PIL import Image, ImageOps, UnidentifiedImageError | |
import os.path | |
def find_files(path, file_names=[], extensions=[]): | |
def valid_file(file_path): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sense_hat import SenseHat | |
def display_acceleration(x, y, z): | |
print("{:06.2f}|{:06.2f}|{:06.2f}".format(x, y, z)) | |
sense = SenseHat() | |
while True: | |
acceleration = sense.get_accelerometer_raw() | |
x = acceleration['x'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sense_hat import SenseHat | |
def display_acceleration(x, y, z): | |
print("{:06.2f}|{:06.2f}|{:06.2f}".format(x, y, z)) | |
sense = SenseHat() | |
while True: | |
acceleration = sense.get_accelerometer_raw() | |
x = acceleration['x'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sense_hat import SenseHat | |
sense = SenseHat() | |
tilt = "flat" | |
def display_orientation(yaw, pitch, roll, tilt): | |
print("{:06.2f}|{:06.2f}|{:06.2f}|{}".format(yaw, pitch, roll, tilt)) | |
while True: | |
pos = sense.get_orientation() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from guizero import App, TextBox, Text | |
def count(): | |
result.value = len(text_to_count.value) - 1 | |
app = App(title="character count") | |
instruction = Text(app, text="Put your text here") | |
text_to_count = TextBox(app, multiline = True, width=60, height=25, command=count) | |
text_to_count.when_key_released = count | |
result = Text(app, text="0") |
NewerOlder