<commit_before># LED Cartography

Experimental LED mapping tools to use alongside Fadecandy.

* Infer layout from physical structure using a camera
* Create linear 16-bit PNG images representing the light contribution from each LED
* Generates Fadecandy config files and Open Pixel Control layouts
* Converts layout to an editable SVG
* Merge edited SVG back into layout

## Dependencies

* [Fadecandy](https://github.com/scanlime/fadecandy) fcserver running
* A DSLR camera that's compatible with gphoto2. I'm using a Canon EOS Rebel T5i
* On Mac OS, you'll want [this mac-gphoto-enabler tool](https://github.com/mejedi/mac-gphoto-enabler) to reversibly disable Mac OS's built-in PTP driver.
* gphoto2, for talking to your camera
* dcraw and netpbm, for decoding RAW images and extracting thumbnails
* OpenCV, for analyzing images
* Node.js and some NPM modules listed in `package.json`

On Mac OS, you can install libgphoto2 and dcraw with Homebrew, but npm needs some help to find the libraries:

    brew install gphoto2 dcraw opencv netpbm
    CXXFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib npm install

## Steps

* Make the environment as dark as possible aside from the LEDs
* Set up the camera
    * Manual white balance, daylight
    * Manual focus
    * Manual exposure, 1/20 or slower
    * Manual ISO 100
    * RAW image format
    * Images should be fairly underexposed, to show as much detail in the highlights as we can get
    * `fadecandy/examples/python/chase.py` is useful for testing the exposure
* Run `photographer.js`. It detects all attached Fadecandy boards, and takes a photo for each LED
    * It uses the camera's thumbnail to detect when the image stops changing, i.e. a particular LED string is done
    * Each LED is photographed in pseudorandom order, to decorrelate any environmental noise from LED position
    * It's always safe to kill and restart this script, it picks up where it left off
* Output files in various formats are now in the data directory!
* To generate a simple 2D layout and fcserver config, run `mapper-2d.js`

## Ideas for later

* Automatically find a good exposure / LED brightness
* Exposure bracketing / HDR
* Support for multiple cameras and 3D reconstruction
* Use detailed per-LED photos for interesting image-based rendering
* Ways to capture the same data using fewer photos.
    * Proof of concept binary mapper in the FC examples
    * Use liveview mode to quickly segment image into nonoverlapping groups of LEDs
<commit_msg>Flags for /usr/local don't seem necessary any more<commit_after># LED Cartography

Experimental LED mapping tools to use alongside Fadecandy.

* Infer layout from physical structure using a camera
* Create linear 16-bit PNG images representing the light contribution from each LED
* Generates Fadecandy config files and Open Pixel Control layouts
* Converts layout to an editable SVG
* Merge edited SVG back into layout

## Dependencies

* [Fadecandy](https://github.com/scanlime/fadecandy) fcserver running
* A DSLR camera that's compatible with gphoto2. I'm using a Canon EOS Rebel T5i
* On Mac OS, you'll want [this mac-gphoto-enabler tool](https://github.com/mejedi/mac-gphoto-enabler) to reversibly disable Mac OS's built-in PTP driver.
* gphoto2, for talking to your camera
* dcraw and netpbm, for decoding RAW images and extracting thumbnails
* OpenCV, for analyzing images
* Node.js and some NPM modules listed in `package.json`

On Mac OS, you can install libgphoto2 and dcraw with Homebrew:

    brew install gphoto2 dcraw opencv netpbm
    npm install

## Steps

* Make the environment as dark as possible aside from the LEDs
* Set up the camera
    * Manual white balance, daylight
    * Manual focus
    * Manual exposure, 1/20 or slower
    * Manual ISO 100
    * RAW image format
    * Images should be fairly underexposed, to show as much detail in the highlights as we can get
    * `fadecandy/examples/python/chase.py` is useful for testing the exposure
* Run `photographer.js`. It detects all attached Fadecandy boards, and takes a photo for each LED
    * It uses the camera's thumbnail to detect when the image stops changing, i.e. a particular LED string is done
    * Each LED is photographed in pseudorandom order, to decorrelate any environmental noise from LED position
    * It's always safe to kill and restart this script, it picks up where it left off
* Output files in various formats are now in the data directory!
* To generate a simple 2D layout and fcserver config, run `mapper-2d.js`

## Ideas for later

* Automatically find a good exposure / LED brightness
* Exposure bracketing / HDR
* Support for multiple cameras and 3D reconstruction
* Use detailed per-LED photos for interesting image-based rendering
* Ways to capture the same data using fewer photos.
    * Proof of concept binary mapper in the FC examples
    * Use liveview mode to quickly segment image into nonoverlapping groups of LEDs

{'fraction_non_alphanumeric': 0.05144824792384039, 'fraction_numerical': 0.006481669029775167, 'mean_word_length': 4.023397761953205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3534621', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1305, 'n_words': 688}