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.
Page Index Toggle Pages: 1
isight / webcam pixelator (Read 529 times)
isight / webcam pixelator
May 7th, 2006, 2:29am
 
hey all, I've been really enjoying processing :)...  here's a program I wrote that does some, I guess, basic pixellations with realtime video.  You can change the size of the x and y grid by the variables at the top.  You can also make it draw ellipses instead of rects if you like, too.  ok, so this is the baby step, now to think of something cooler than these basic things to do with this.. :)

Quote:


/*  webcam pixelator!! wait, is there a faster way to do this?
// steve cooley
// 2006-05-06
*/

import processing.video.*;

Capture myCapture;  

// split the screen by:
int gridsizex = 16;
int gridsizey = 48;


// String rectorellipse = "rect";
String rectorellipse = "ellipse";

void setup()  
{  
 framerate(10);
 size(640/2, 480/2, P3D);  
 println(Capture.list()); // to output which cam is connected, then copy that text into the string below

 String s = "IIDC FireWire Video";  

 myCapture = new Capture(this, s, width, height, 30);
 noStroke();
 rectMode(CORNER);
}

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

}

//
// get the size of the window
// divide the window by x across and y down
// for every time in the x and y divisions, get the pixel color at that location
// draw a box (or ellipse) on that spot with that color
//


void draw() {
 image(myCapture, 0, 0);
 // fill(0);
 // rect(0,0,width,height);

 for(int y = 0; y<height; y=y+(height/gridsizey))
 {
   // println(y);
   for(int x = 0; x<width; x=x+(width/gridsizex))
   {
     // println(x);
     color cp = get(x, y);
     fill(cp);
     if(rectorellipse == "rect")
     {
       rect(x, y, width/gridsizex, height/gridsizey);
     }
     else
     {
       ellipse(x, y, width/gridsizex, height/gridsizey);
     }
   }
 }

}



Page Index Toggle Pages: 1