Skip to main content

A library for displaying arrays as video in Python.

Display arrays while updating them

from displayarray import display
import numpy as np

arr = np.random.normal(0.5, 0.1, (100, 100, 3))

with display(arr) as d:
    while d:
        arr[:] += np.random.normal(0.001, 0.0005, (100, 100, 3))
        arr %= 1.0

Run functions on 60fps webcam or video input

image0

(Video Source: https://www.youtube.com/watch?v=WgXQ59rg0GM)

from displayarray import display
import math as m

def forest_color(arr):
    forest_color.i += 1
    arr[..., 0] = (m.sin(forest_color.i*(2*m.pi)*4/360)*255 + arr[..., 0]) % 255
    arr[..., 1] = (m.sin((forest_color.i * (2 * m.pi) * 5 + 45) / 360) * 255 + arr[..., 1]) % 255
    arr[..., 2] = (m.cos(forest_color.i*(2*m.pi)*3/360)*255 + arr[..., 2]) % 255

forest_color.i = 0

display("fractal test.mp4", callbacks=forest_color, blocking=True, fps_limit=120)

Display tensors as they’re running through TensorFlow or PyTorch

# see test_display_tensorflow in test_simple_apy for full code.

...

autoencoder.compile(loss="mse", optimizer="adam")

while displayer:
    grab = tf.convert_to_tensor(
        displayer.FRAME_DICT["fractal test.mp4frame"][np.newaxis, ...].astype(np.float32)
        / 255.0
    )
    grab_noise = tf.convert_to_tensor(
        (((displayer.FRAME_DICT["fractal test.mp4frame"][np.newaxis, ...].astype(
            np.float32) + np.random.uniform(0, 255, grab.shape)) / 2) % 255)
        / 255.0
    )
    displayer.update((grab_noise.numpy()[0] * 255.0).astype(np.uint8), "uid for grab noise")
    autoencoder.fit(grab_noise, grab, steps_per_epoch=1, epochs=1)
    output_image = autoencoder.predict(grab, steps=1)
    displayer.update((output_image[0] * 255.0).astype(np.uint8), "uid for autoencoder output")

Handle input events

Mouse events captured whenever the mouse moves over the window:

event:0
x,y:133,387
flags:0
param:None

Code:

from displayarray.input import mouse_loop
from displayarray import display

@mouse_loop
def print_mouse_thread(mouse_event):
    print(mouse_event)

display("fractal test.mp4", blocking=True)

Installation

displayarray is distributed on PyPI as a universal wheel in Python 3.6+ and PyPy.

$ pip install displayarray

Usage

API has been generated here.

See tests and examples for example usage.

License

displayarray is distributed under the terms of both

at your option.

Metadata

Release files for displayarray 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for displayarray 1.3.1
File Size Uploaded
displayarray-1.3.1.tar.gz 22.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for displayarray 1.3.1
File Interpreter ABI Platform
displayarray-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 51.8 kB

Release files / displayarray-1.3.1.tar.gz

Download URL displayarray-1.3.1.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b0f5cc4d06d44750faf73c8d8568d6b288ea98839a82687109722a93b59a7cdd
BLAKE2b-256 checksum
How to use checksums
ecfae64876bbc2633aa7235edcc9085ef10fa0be8b39b2944c3cd4996e3eb073
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / displayarray-1.3.1-py3-none-any.whl

Download URL displayarray-1.3.1-py3-none-any.whl
Size 29.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9f3247b7bbf8f579b8ae4062587ab089f3f69a8979749120e3916a22aef9377
BLAKE2b-256 checksum
How to use checksums
0596099ca161bd63aac710f077a7d21002a79ebb25962188b158b2973cdf5774
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page