We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › extrusion+webcam
Page Index Toggle Pages: 1
extrusion+webcam (Read 296 times)
extrusion+webcam
Oct 29th, 2009, 6:48am
 
hi

i am trying to combine the "extrusion" sketch found in the examples folder of processing, with a simple video input.

what i want, basically, is a video input where the brightness of a pixel controls the z factor of its position.

here's my newbie code;

import processing.video.*;
Capture myCapture;

PImage extrude;
int[][] values;
float angle = 0;

void setup()
{
 size(500, 400, P3D);
 myCapture = new Capture(this, width, height, 30);
 
 extrude.loadPixels();
 values = new int[extrude.width][extrude.height];
 for (int y = 0; y < extrude.height; y++) {
   for (int x = 0; x < extrude.width; x++) {
     color pixel = extrude.get(x, y);
     values[x][y] = int(brightness(pixel));
   }
 }
 
}

void captureEvent(Capture myCapture) {
 myCapture.read();
}

void draw() {
 image(myCapture, 0, 0);
 
   for (int y = 0; y < extrude.height; y++) {
   for (int x = 0; x < extrude.width; x++) {
     stroke(values[x][y]);
     point(x, y, -values[x][y]);
   }
 }
 
}


the next step involves sending out the z-values of one particular line to max/msp for a 2dwave oscillator!

hope someone can help me figure out this problem first though... thanks!

-dataplex
Page Index Toggle Pages: 1