Giter Club home page Giter Club logo

lightwork's Introduction

Lightwork BETA

Lightwork GIF

Lightwork simplifies the process of mapping complex arrangements of LEDs, removing the limitations of straight lines and grids from your light based creations.

Features

  • Compatible with Fadecandy, Pixelpusher, sACN and ArtNet driven LED arrays
  • Network discovery for Pixelpusher and ArtNet nodes
  • GUI controls for LED array configuration and OpenCV mapping calibration
  • Sequential mapping - Fire and detect LEDs one at a time, sequentially. Slow for large arrays but more reliable in some cases
  • Binary mapping - LEDs flash a unique binary pattern, and all LEDs are mapped simultaneously. Exponentially faster for large arrays, but more suceptible to lighting/environmental interference
  • Save as CSV for use with the included Scraper, or applications like MadMapper / Touchdesigner
  • Lightweight scraper that can be added to your application to drive LEDs
  • Seamless map updates while the scraper is running, over OSC
  • (Experimental) Stereo mode captures 3D coordinates by mapping from 2 camera locations

How it Works

Lightwork uses OpenCV to detect and map your LED arrangements. Set up your LEDs, point a webcam at them, run Lightwork and you'll have a comprehensive map that enables you to put content on them as if they were a screen.

Here's a video walking through the binary mapping process: Lightwork Tutorial

Requirements

Libraries: PixelPusher, OpenCV, ControlP5, eDMX, oscP5

Most available from the Sketch > Import Library > Add Library dialog in the Processing IDE.

*Scraper includes Syphon (Mac) and Spout (Win) client to receive content from another application. You'll need the appropriate library for your platform. This is optional, comment and remove the PDE if you don't need this functionality.

Operating System

Tested and developed in OSX 10.12 and Windows 10, may not behave well in other operating systems.

A Webcam

We recommend, and have built this using the Logitech C920 webcam. It's cheap, is tripod mount compatible, and generally provides high quality and high speed capture.

Hardware

PixelPusher, Fadecandy or Artnet controller and individually addressable LEDs are required.

1440x900 or higher resolution monitor recommended.

Hardware Setup Reference

This readme assumes you have set up your driver hardware and LEDs first. Here are some references to get you started if this is your first time:

PixelPusher setup reference: https://sites.google.com/a/heroicrobot.com/pixelpusher/home/getting-started

FadeCandy: https://github.com/scanlime/fadecandy

This guide is very useful for setting up a raspberry pi to drive FadeCandy controllers over network: https://learn.adafruit.com/1500-neopixel-led-curtain-with-raspberry-pi-fadecandy/fadecandy-server-setup

ArtNet: Consult your hardware’s manual for setup. (ArtNet support is currently incomplete)

LightWork Mapper

Lightwork Mapper Screenshot

The application used to map your LED array. Use an attached webcam to capture LED states and translate their physical locations into screen locations. Outputs a normalized CSV of LED locations for use in the Lightwork Scraper, or any software of your choice.

Quick Start Guide

Set up your LEDs, their controller and ensure you can connect to it either locally or over network.

Connect your webcam, and point it at the LED array. We recommend a tripod to allow positioning your cam as needed, and keeping it stable. Any movement will throw off your mapping results. Be sure to turn off "Auto" features on your webcam, like auto focus and auto white balance, these will make adjustments between frames while mapping, affecting results.

Select your camera from the dropdown, and its output should appear. If it's not in the list, hit "Refresh"

Select your LED controller type from the dropdown, and enter the appropriate details. Make sure to hit enter after changing settings. Once your settings are correct hit "Connect". On successful connect, the button will change to "Refresh", allowing you to reconnect with different settings.

Now that you're connected, you can calibrate the OpenCV view to your LEDs and lighting conditions. Default is pattern mode, but you can also choose sequential for more challenging setups. Adjust the contrast and threshold until your lit LEDs appear well defined white blobs in the right window. In general, keep the LED brightness as low as possible to prevent flaring in the camera.

Once you have the CV settings looking good, you're almost ready to map. The settings on the right are mapping controls. Frameskip controls the number of frames between captures, or the speed mapping runs at. Turn this up for more reliable results. Blob size controls the allowed size of blobs. The minimum should be set to detect actual LEDs but filter our noise. Max should be set to around the size of LEDs but small enough to filter out blobs that blend together due to flaring. Blob distance is used to filter duplicate blobs or blobs that appear very close together, often caused by flaring. These settings will depend on your setup and environmental settings, so adjust until you get the desired result.

Now you can stop calibrating, and try mapping. Binary will capture a sequence of frames, then analyze them for patterns before returning the number of matched LEDs. Adjust your settings until you get the expected number of matched LEDs. Sequential will show an ellipse at the location of detected LEDs, but not the total number.

Once Mapping is complete, press "Stop" and "Save Layout". This will open a save dialog that should default to the Lightwork Scraper directory. The window may appear behind other open windows, which is a java issue, just al+tab to it. Make sure you add .csv to the saved file name.

And that's it! You can now use the generated map in the Lightwork Scraper or another software of your choice.

UI control reference:

Camera: select a connected USB webcam

Refresh: refreshes the list of connected webcams - if a camera only shows black, unplug it and then refresh (this is to do with OS drivers not releasing properly)

Stereo Toggle: Enable multiple captures for depth mapping. Estimates Z depth based on 2 captures. Once enabled, you'll need to use Map Left and Map Right before saving the layout.

FPS: Number in the top right is the current framerate, useful for performance testing.

Driver: LED driver hardware. Currently FadeCandy and PixelPusher are supported (Artnet is incomplete). Selecting a driver from the dropdown will reveal the required settings to connect. Pixelpusher configuration is stored on its USB, and will be discovered over network.

IP: The local IP of the driver hardware. Use 127.0.0.1 for a USB connected fadecandy. Press enter to set the value.

Strips: Number of strips connected to the driver hardware. Press enter to set the value.

LEDs per strip: Number of LEDs on each attached strip. Use the longest string if they aren’t consistent. Note that FadeCandy supports a max of 64 per channel, and PixelPusher supports a max of 480 per channel. Press enter to set the value.

Connect: Connect to driver hardware using current settings. Button turns green on successful connection. Once connected, this button can be used to update the strip settings on the driver hardware.

Contrast: Adjusts the contrast on the OpenCV input. Useful for compensating for ambient lighting.

Threshold: OpenCV is performed on a binary image (black and white). Pixels above the threshold become white, pixels below the threshold become black. Use to isolate your LEDs in a noisy scene.

LED Brightness: 0-255. This can help reduce lens flaring, or compensate for ambient light in a scene.

Pattern/ Sequence: Select mapping method.

Sequence fires the LEDs in order of their address, and associates them with a physical location one at a time. Sequential can be very accurate, but is slower on large arrays. Sequential is also beneficial on arrays where the LEDs are very close together or when their light blends.

Pattern flashes the full LED array in binary patterns, capturing a video frame for each bit of the pattern. Once captured, the patterns are associated with their physical location, all at once. Binary mapping is an exponential decrease in mapping time as the number of LEDs increases, but is not suitable for all arrangements.

Calibrate: Run a test to check physical connections and ensure all LEDs are working. Also useful for adjusting settings to compensate for ambient lighting or other environmental factors. Press Calibrate again to stop.

Map: Run the selected mapping method. This will display detected LED locations in the output window. Runs until mapping is complete.

Frameskip Amount of frames to wait between animator actions. Lower numbers speed up mapping but can reduce accuracy.

Min/ Max Blob Size: Isolate size of blobs elegible for detection. Increasing minimum size helps eliminate noise, increasing maximum size helps compensate for larger LEDs.

Min Blob Distance: Minimum distance between detected blobs. Blobs closer than this will be filtered out as erroneous.

Save Layout: Saves a CSV of the mapping layout, to be used in the Lightwork Scraper.

Keyboard Controls:

ALT-SHIFT-S : Save UI properties to file

ALT-SHIFT-L : Load UI properties to file

Note: ALT also enables dragging in ControlP5, try to release the alt key first after using these commands. If it's releases last it can enable dragging.

SHIFT-H : Disable dragging (if activated with alt)

Lightwork Scraper

Lightwork Scraper Screenshot

Use with your own sketch to map your content onto the LED array.

Requires Interface.pde, OPC.pde and Scraper.pde in your sketch folder, as well as a layout CSV in the sketch or data folder.

Replace the drawing code in the example to display your own content, or use Syphon/Spout to pipe in input from another application.

Example Setup:

void setup() {
  size(1280, 960, P3D);

  //initialize scraper
  //replace with your filename, make sure it's in the sketch or /data folder
  scrape = new Scraper("layout.csv");

  //initialize connection to LED driver - replace with adress and LED config for your setup
  //(Device type, address (not required for PixelPusher), number of strips, LEDs per strip)
  network = new Interface(device.FADECANDY, "fade2.local", 3, 50);
  network.connect(this);

  //update scraper after network connects
  scrape.update();
}

Example draw loop:

void draw() {
  //Your drawing code here

  //Scraper functions
  scrape.update(); //Update colors to be sent to LEDs
  network.update(scrape.getColors()); //Send colors to LEDs
  scrape.display(); //Show locations loaded from CSV
}

Developed with the participation of Creative BC, the Province of British Columbia and the British Columbia Arts Council.

CBCBCACLogos

lightwork's People

Contributors

brainmachine avatar timrolls avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lightwork's Issues

Question about the method

This is a great project thanks. I'm trying to figure out if I could have used it on a recent project.

I'm not raising an issue, more of a question about understanding the method:

  1. Does the identification of the LEDs happen in closed-loop with the webcam or is the excitation sequence generated first, then fed to the LEDs, and then the resulting webcam video analysed after-the-fact?

  2. Is the final output the simply the physical co-ordinates of the LEDs (x, y) or does it also determine the mapping of intensity-values to webcam brightness?

I tried to figure out the answer myself but wasn't clear from the description.
Thanks.

Behavior after binary mapping needs improvement

Current cycling through captured frames is not clear what is happening or whether it was successful.

Examples>Video>Capture>FramingHam
Could work as a solution - show all captured frames at once

Update UI controls

Need to add:
Frameskip 6-30
Blob size Min/Max
DIstance Threshold
Mapping type radio button or separate binary and sequential buttons

Remove:
Video Switch
Console Window (doesn't behave correctly)

Add recommended settings to documentation

Ie: pattern mapping in situations where they don't bleed together, or sequential then they're harder to see from one spot.

Also disable autofocus and whitebalance in camera settings for best results

support to other LED hardware

Maybe not a place to leave this thought...but.. I find the Lightwork Mapper fascinating but I don't use the LED controllers listed and cannot work out how to interface. There are some very simple interfaces out there and I currently use wireless control using ESP2866 boards and the WLED software … see https://github.com/Aircoookie/WLED . This is still a network run system can anyone help to interface this into the Lightwork_Mapper. Thanks DW

Artnet is limited to 1 universe

Incrementing universes could be quick to implement.
Supporting multiple hardware connections simultaneously may not be.

We need hardware to test thoroughly.

ArtNet Calibration Freezes after first pattern

was able to get the Mapper and Scraper working in Ubuntu Studio 18.04 with a fade candy, but when i tried to use it with an ESP8266 Running an ArtNetNode Firmware ( https://github.com/bombcheck/ESP8266_ArtNet-LED-DMX-Node ) it seems to fail after the first calibration pattern is displayed (just changes the LEDs once) and displays the following error in the processing window:
ArrayIndexOutOfBoundsException: 48
and the Interface seems to freeze, and does not respond to clicks.

please let me know if there is any insight into this issue, thanks.

and big ups to the creator(s) of this awesome little tool for pixel mapping...hope to be able to put it to use playing video from veejay via v4l2loopback with a WiFi enabled esp8266 over ArtNet or sACN

screenshot_2018-12-19_20-57-39

We need a tutorial video

Detailing the workflow of using the software.
Listing functions isn't enough for people to get started using it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.