Пример #1
0
class Display:
    def __init__(self, saturation=0.5):
        self.inky = Inky()
        self.saturation = saturation

    def resize_for_screen(self, image):
        copied = image.copy()

        # Apply rotation in exif data
        copied = ImageOps.exif_transpose(image)

        copied.thumbnail([600, 448])
        size = copied.size
        print(size)
        background = Image.new("RGB", (600, 448), (255, 255, 255))
        background.paste(copied, (int(
            (600 - size[0]) / 2), int((448 - size[1]) / 2)))
        return background

    def _show_latest(self):
        latest_image = self.resize_for_screen(Image.open("latest"))

        self.inky.set_image(latest_image, saturation=self.saturation)
        self.inky.show(busy_wait=False)
        print("done")

    def show_latest(self):
        task = threading.Thread(target=self._show_latest, args=())
        task.start()
Пример #2
0
        data=mpg)

if args.dataset == "penguins":
    palette = seaborn.color_palette(palette_colors, n_colors=3)
    df = seaborn.load_dataset("penguins")
    plot = seaborn.pairplot(df, hue="species", palette=palette)

if args.dataset == "dots":
    palette = seaborn.color_palette(palette_colors, n_colors=6)
    dots = seaborn.load_dataset("dots")
    plot = seaborn.relplot(
        data=dots,
        x="time", y="firing_rate",
        hue="coherence", size="choice", col="align",
        kind="line", size_order=["T1", "T2"], palette=palette,
        facet_kws=dict(sharex=False),
    )

# Force the output plot to be approximately the right size for Inky
pyplot.gcf().set_size_inches(inky.width / dpi, inky.height / dpi)

plot.savefig(buf, format="png", dpi=dpi)
buf.seek(0)

plot_image = Image.open(buf).convert("RGB")
image = Image.new("RGB", (inky.width, inky.height), (255, 255, 255))
image.paste(plot_image, (0, 0))

inky.set_image(image, saturation=saturation)
inky.show()
Пример #3
0
if len(sys.argv) == 1:
    print("""
Usage: {file} image-file
""".format(file=sys.argv[0]))
    sys.exit(1)

if len(sys.argv) > 2:
    saturation = float(sys.argv[2])

palette = hitherdither.palette.Palette(
    inky._palette_blend(saturation, dtype='uint24'))

image = Image.open(sys.argv[1]).convert("RGB")
# VERY slow (1m 40s on a Pi 4) - see https://github.com/hbldh/hitherdither for a list of methods
# image_dithered = hitherdither.diffusion.error_diffusion_dithering(image, palette, method="stucki", order=2)

# Usably quick, your vanilla dithering
# image_dithered = hitherdither.ordered.bayer.bayer_dithering(image, palette, thresholds, order=8)

# Usuably quick, half-tone comic-book feel, use order=4 for small dots and order=8 dot bigguns
image_dithered = hitherdither.ordered.cluster.cluster_dot_dithering(image,
                                                                    palette,
                                                                    thresholds,
                                                                    order=8)

# VERY slow
# image_dithered = hitherdither.ordered.yliluoma.yliluomas_1_ordered_dithering(image, palette, order=8)

inky.set_image(image_dithered.convert("P"))
inky.show()
Пример #4
0
                thermal_camera.condition.wait()
                if capture == True:
                    print('Capture image')
                    time.sleep(5)
                    print('Ready')

                    capture = False
                    frame = thermal_camera.frame
                    vmin = min(frame)
                    vmax = max(frame)
                    img = Image.new('RGB', (32, 24), 'black')

                    for y in range(24):
                        for x in range(32):
                            val = frame[32 * (23 - y) + x]
                            rgb = thermal_camera.temperature_to_color(
                                val, vmin, vmax)
                            img.putpixel((x, y), rgb)

                    #img = img.transpose(Image.ROTATE_270).transpose(Image.FLIP_LEFT_RIGHT)
                    img = img.resize((600, 448), Image.BICUBIC)
                    inky.set_image(img, saturation=0.5)
                    inky.show()

                    print('Done')

    except:
        print('Error')
    finally:
        thermal_camera.stop_recording()