pimoroni / st7789-python

Python library to control an ST7789 240x240 1.3" TFT LCD display.
MIT License
193 stars 51 forks source link

add support to display opencv images #11

Closed zecktos closed 3 years ago

zecktos commented 3 years ago

This is a small change to display opencv images, as they are already numpy arrays. This makes it easy to play video files or camera capture. Make sure to call image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) before you pass the image to display().

Gadgetoid commented 3 years ago

Nice addition, thank you!

Could probably de-dupe some code and make it clearer about intent like so:

if type(image) is not np.ndarray:
    image = np.array(image.convert('RGB'))

pb = image.rot90(image, rotation // 90).astype('uint8')

May need to add a test case for this, but I appreciate this code path is currently utterly untested so I might have to fix that.

zecktos commented 3 years ago

Oh yes this is a more elegant way