Created
February 21, 2019 14:04
-
-
Save bmidgley/9e6a9c8e236fa470bb0ae7d68e4975d8 to your computer and use it in GitHub Desktop.
capture from camera in raw format for display
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 python3 | |
import cv2 | |
import io | |
import time | |
import picamera | |
import Adafruit_SSD1306 | |
import numpy as np | |
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(image): | |
image = Image.fromarray(image).convert('1').transpose(Image.FLIP_LEFT_RIGHT) | |
disp.image(image) | |
disp.display() | |
return(False) | |
with picamera.PiCamera() as camera: | |
camera.resolution = (128, 64) | |
image = np.empty((64, 128, 3), dtype=np.uint8) | |
while True: | |
camera.capture(image, format='bgr') | |
if process(image): | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment