So have kind of an off the wall question. I recently purchased a number of LED addressable strips from Sparkfun. The things are amazing, however, it seems that the red and blue inputs are reversed. When I run a test sketch and flood the wall with red, then green, then blue, it actually comes out blue, then green, then red. I'm think this is a hardware issue with the strips but am wondering how I can invert those two colors in my processing sketch.
The sketch itself is utilizing Syphon (info can be found here if you are not familiar with it
http://syphon.v002.info), and a MAX patch to take video information captured from my desktop and making it available as a Syphon server, which is then grabbed by the Processing sketch and piped out to an Arduino Uno that pushes that video information out to the LED array mentioned early.
Long story short, what is the best way to invert just the red and blue values so that way my video information actually looks like what is being captured from the desktop?
Any information would be grand.
Here are the pieces:
Processing:
import codeanticode.syphon.*;
import processing.serial.*;
import java.awt.*;
import java.awt.image.*;
// GLOBAL VARIABLES ---- You probably won't need to modify any of this -------
byte[] serialData = new byte[6 + leds.length * 3];
short[][] ledColor = new short[leds.length][3],
prevColor = new short[leds.length][3];
byte[][] gamma = new byte[256][3];
int nDisplays = displays.length;
Robot[] bot = new Robot[displays.length];
Rectangle[] dispBounds = new Rectangle[displays.length],
ledBounds; // Alloc'd only if per-LED captures
int[][] pixelOffset = new int[leds.length][256],
screenData; // Alloc'd only if full-screen captures
DisposeHandler dh; // For disabling LEDs on exit
PGraphics S_img;
SyphonClient client;
Serial port;
static final short minBrightness = 0;
static final short fade = 75;
static final int pixelSize = 20;
static final boolean useFullScreenCaps = true;
static final int timeout = 5000; // 5 seconds
static final int displays[][] = new int[][] { {0,32,16} };
So I have been in the works of developing a mod to the Brightness Tracking code in the Examples section under Libraries > Video (as a point of reference as to where I started). The goal is to have the brightest pixel tracked and draw a line based on that pixels color. I have everything set now so that a line is drawn as it tracks whatever is the brightest pixel, but the color is hard coded. The problem is that I am not sure how to drive the stroke color based on that tracked pixel. Any help would be appreciated.
Here is what I have so far.
int oldX = 0;
int oldY = 0;
import processing.video.*;
Capture video;
void setup() {
size(320, 240); // Change size to 320 x 240 if too slow at 640 x 480
// Uses the default video input, see the reference if this causes an error
//background (0);
video = new Capture(this, width, height, 30);
noStroke();
smooth();
}
void draw() {
if (video.available()) {
video.read();
image (video, 0, 0, width, height); // Draw the webcam video onto the screen
int brightestX = 0; // X-coordinate of the brightest video pixel
int brightestY = 0; // Y-coordinate of the brightest video pixel
float brightestValue = 0; // Brightness of the brightest video pixel
// Search for the brightest pixel: For each row of pixels in the video image and
// for each pixel in the yth row, compute each pixel's index in the video
video.loadPixels();
int index = 0;
for (int y = 0; y < video.height; y++) {
for (int x = 0; x < video.width; x++) {
// Get the color stored in the pixel
int pixelValue = video.pixels[index];
// Determine the brightness of the pixel
float pixelBrightness = brightness(pixelValue);
// If that value is brighter than any previous, then store the
// brightness of that pixel, as well as its (x,y) location