Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

05 Videofilter

Februar 27, 2012

import processing.video.*;

int breite = width;
int hoehe = height;

// Step 2. Declare a Capture object
Capture video;

void setup() {
size(1024,768);

println(Capture.list());

// Step 3. Initialize Capture object via Constructor
// video is 320 x 240, @15 fps
video = new Capture(this,1024,768,"IIDC FireWire Video",15);
}

void draw() {

// Check to see if a new frame is available
if (video.available()) {
// If so, read it.
video.read();
}

loadPixels();
video.loadPixels();

for (int x = 0; x < video.width; x++) {
for (int y = 0; y < video.height; y++) {

// Calculate the 1D location from a 2D grid
int loc = x + y*video.width;

// Get the R,G,B values from image
float r,g,b;
r = red (video.pixels[loc]);
g = green (video.pixels[loc]);
b = blue (video.pixels[loc]);

// Calculate an amount to change brightness based on proximity to the mouse
float maxdist = 100;// dist(0,0,width,height);
float d = dist(x,y,mouseX,mouseY);
float adjustbrightness = (maxdist-d)/maxdist;
r *= adjustbrightness;
g *= adjustbrightness;
b *= adjustbrightness;

// Constrain RGB to make sure they are within 0-255 color range
r = constrain(r,0,255);
g = constrain(g,0,255);
b = constrain(b,0,255);

// Make a new color and set pixel in the window
color c = color(r,g,b);
pixels[loc] = c;
}
}
updatePixels();
}