Last active
February 20, 2019 04:50
-
-
Save bmidgley/3cb92261c6927453b2f6c0d89d9645b0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
import io | |
import time | |
import picamera | |
import Adafruit_SSD1306 | |
from Adafruit_GPIO import SPI | |
from PIL import Image | |
RST = 24 | |
DC = 23 | |
SPI_PORT = 0 | |
SPI_DEVICE = 0 | |
disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, dc=DC, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000)) | |
disp.begin() | |
disp.clear() | |
disp.display() | |
def process(stream): | |
image = Image.open(stream).convert('1').transpose(Image.FLIP_LEFT_RIGHT) | |
disp.image(image) | |
disp.display() | |
return(False) | |
with picamera.PiCamera() as camera: | |
camera.resolution = (128, 64) | |
stream = io.BytesIO() | |
while True: | |
stream.seek(0) | |
camera.capture(stream, format='jpeg') | |
stream.truncate() | |
stream.seek(0) | |
if process(stream): | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment