Pixelblaze-client Python Library Release: Updated and Upgraded!

With the addition of @pixie as a key contributor, I am pleased to announce the release of v1.0.0 - the first finished, non-beta version - of the pixelblaze-client library for Python.

This library presents an easy-to-use interface for controlling one or more Pixelblazes from a Python program. This version goes beyond the previous version’s control of run-time parameters and enables your Python programs to do virtually everything the Pixelblaze web interface can do. For instance, you can:

  • Find Pixelblazes on your network
  • Read and modify variables and controls in Pixelblaze patterns
  • Back up and restore your Pixelblaze
  • Work with EPE files
  • Control Pixelblaze settings, including maps

and much more. See the documentation for details.

In the course of this expansion, the API has changed. So if you’ve used the library before, take a look at the documentation before upgrading. Chances are, you’ll need to modify existing programs to use the new library. But given the new capabilities available, it’s worth the trouble.

You can install the library from pypi: pip install pixelblaze-client

Source code, examples, complete API documentation, and additional instructions on installation and usage are available via the project’s github repository.

And thanks @pixie, for turning the power up to 11! This is your release, and I am impressed, inspired and grateful.

3 Likes

The new version of the library came about because I was playing around with rendering animated previews of patterns from the information inside the pattern files. The preview images stored in the pattern files are limited to 100 pixels and 150 frames, but (thanks to some hints from @wizard) I was able to work out a way to read the live previews of the LEDs from a real live Pixelblaze using @zranger1’s pixelblaze-client library, arrange them in space according to the pixelmap, and render them as 1D/2D/3D animations. Here’s what “Cube Fire 2D/3D” looks like on a variety of different layouts:

cube fire 3D cube fire 3D cube fire 3D cube fire 3D

I asked @zranger1 if I could make a few changes to his library to make the preview capture easier, he graciously said yes, and from there it just snowballed. I got the animations I wanted, but then I thought…why stop there? As many of you will appreciate, once you start tinkering it’s hard to stop.

Here are a few examples of what you can do with the new library:


RECORDVIDEO

Think of it as a VCR for Pixelblaze patterns. When run, it will begin capturing whatever is on the LEDs into a 2D buffer. When you’ve recorded enough, press [Ctrl]-[C] and it will begin rendering the captured frames into an animated PNG suitable for inserting into forum posts. If you want an MP4 instead, convert the PNG afterwards with ffmpeg -i {filename}.png {filename}.mp4.

Syntax

The syntax is:

usage: recordVideo.py [-h] [--ipAddress IPADDRESS] [--fileName FILENAME]
options:
  -h, --help                show this help message and exit
  --ipAddress IPADDRESS     The IP address of the Pixelblaze to record
  --fileName FILENAME       The filename for the recording to be created

~*~

And what good is a VCR without something to play on it? I remembered @zranger1’s E.131 proxy and realized that the same technique could be used to serve any kind of content to a Pixelblaze. There’s a new example program in the pixelblaze-client library that will play animated GIFs and PNGs onto a nearby Pixelblaze:

pacmanGhost => played to a 32x32 matrix => Pixel Proxy

…but what I really want, what I really really want is video. Fortunately, Python is the duck tape of the internet; with only a few changes to the example program we can use OpenCV to read videos frame-by-frame and send them to a Pixelblaze.


PLAYVIDEO

If OpenCV can read it, you can play it on your Pixelblaze. It has a ways to go before it will replace your home theater setup, but nevertheless it’s amazing what these little things can do!

Syntax

The syntax is:

usage: playVideo [-h] --ipAddress IPADDRESS --fileName FILENAME
options:
  -h, --help                show this help message and exit
  --ipAddress IPADDRESS     The IP address of the Pixelblaze
  --fileName FILENAME       The video file to be sent to the Pixelblaze, or 'webcam' to use the webcam

~*~

So turn your speakers up, find a comfy chair, and prepare to be amazed by the wonders of moving pictures, as played through a Pixelblaze:


Installation

The pixelblaze-client library is a prerequisite, naturally. If you don’t have it, pip install pixelblaze-client.

The source code is here:

recordVideo.py (8.1 KB) and playVideo.py (5.7 KB)

And if you chmod +x the Python files, you’ll be able to execute them directly from the command line without having to specify python in front.

8 Likes

and a bonus rickroll ! lol