Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Processing DMX Bridge

Um Daten von Processing an DMX (siehe Wikipedia) zu übergeben nutzen wir ein Arduino als Brücke. Auf das Arduino setzen wir das DMX Shield und programmieren es mit dem folgenden Code

...

Code Block
languagejava
titleBeispiel RGB über DMX Senden
collapsetrue
 import processing.serial.*;  // Import the Processing Serial Library for communicating with arduino
Serial dmxPort;               // The used Serial Port

int[][] dmxValues; //First dimension = number of DMX channels //Second dimension = channel, value
int amountOfDMXChannels = 3;

void setup()
{
  background(0);
  size(500, 500);
  println(Serial.list()); // Prints the list of serial available devices (Arduino should be on top of the list)
  dmxPort = new Serial(this, Serial.list()[Serial.list().length-1], 9600); // Open a new port and connect with Arduino at 9600 baud

  dmxValues = new int[amountOfDMXChannels][2];
  dmxValues[0][0] = 0;
  dmxValues[1][0] = 1;
  dmxValues[2][0] = 2;
}

void draw()
{
  background(0);
  color c = color(map(mouseX,0,width,0,255),map(mouseY,0,height,0,255),0);
  text("R: "+red(c)+"\t G: "+green(c)+"\t B: "+blue(c), 20, 20);
  dmxValues[0][1] = int(red(c));
  dmxValues[1][1] = int(green(c));
  dmxValues[2][1] = int(blue(c));
  sendDMX(dmxValues);
}

void sendDMX(int valuesToSend[][])
{
  for (int i=0; i<valuesToSend.length; i++)
  {
    dmxPort.write(str(valuesToSend[i][0]));
    dmxPort.write(",");
    dmxPort.write(str(valuesToSend[i][1]));
    dmxPort.write("\n");
  }
}

//Spatial Interaction
//ZHdK, Interaction Design
//iad.zhdk.ch
//Beispiel 8: Kamerabild BlobDetection

import processing.video.*;
Capture video;

BlobDetection blobDetector;
color blobColor; 

void setup() 
{
  size(640, 480);

  video = new Capture(this, width, height, 15);
  video.start();
  
  blobDetector = new BlobDetection();
  blobColor = color(255, 0, 0);

  smooth();
}

void draw() 
{
  if (video.available()) 
  {
    video.read();
  }
  video.loadPixels();
  //video.filter(THRESHOLD,0.1); //For black and white image
  image(video, 0, 0);
  
  blobDetector.findBlob(video, blobColor, 20); 
  blobDetector.drawBlob();
  blobDetector.drawBox();
  blobDetector.drawCoM();
}

void mousePressed() 
{
  int loc = mouseX + mouseY*video.width;
  blobColor = video.pixels[loc];
}

Einstellungen an den DMX Empfängern (Leuchten, Scanner usw.)

...