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
pixel blocking the webcam (Read 1048 times)
pixel blocking the webcam
May 25th, 2005, 10:10pm
 
Combining the two script exmaples I was able to quickly mash out: http://pixelplay.org/jeff/T2/blocking.jpg

import processing.video.*;

float i = 1.0;
float n = 1.0;
Capture camera;

int numPixels;
int blockSize = 5;
color myMovieColors[];

void setup()

{
 size(800, 600);
 framerate(29);

 //println(Capture.list());

String s = "Logitech QuickCam Zoom-WDM";

 noStroke();
 background(244,244,224);
 camera = new Capture(this, s, 240, 180, 29);
 numPixels = width / blockSize;
 myMovieColors = new color[numPixels * numPixels];


}

void captureEvent(Capture camera)
{
camera.read();
for(int j=0; j<numPixels; j++) {
  for(int i=0; i<numPixels; i++) {
     myMovieColors[j*numPixels + i] = camera.get(i, j);
   }
 }
}

void draw()
{
for(int j=0; j<numPixels; j++) {
   for(int i=0; i<numPixels; i++) {
     fill(myMovieColors[j*numPixels + i]);
     rect(i*blockSize, j*blockSize, blockSize-3, blockSize-3);
   }
 }
}


So pixel fetching seems to work fine. kudos to the Processing team for this object!

Re: pixel blocking the webcam
Reply #1 - May 26th, 2005, 10:55am
 
made a little something myself
http://wliia.org/projects/video/screen-0211.jpg

Code:

import processing.video.*;

Capture Scamera;
Pixie[] pix;
int skip = 5;

void setup()
{
size(320, 240, P3D);
framerate(20);
noStroke();
String s = "Creative WebCam Live!-WDM";
Scamera = new Capture(this, s, width, height, 30);
pix = new Pixie[width*height];
for(int i = 0; i < width; i++)
{
for(int j = 0; j < height; j++)
{
pix[j*width+i] = new Pixie(i,j,15,56,2); // set 2 to 1 if you want elipses, and 15 and 56 are minSize and maxSize..
}
}
}

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

void draw()
{
//background(100); // for lots of gray area, activate this
for(int i = 0; i < width; i+=skip)
{
for(int j = 0; j < height; j+=skip)
{
pix[j*width+i].render();
}
}
}

void mousePressed()
{
saveFrame();
}

class Pixie
{

int x, y, w, h, mode, minS, maxS;
color c;
Pixie(int x, int y, int minS, int maxS, int mode)
{
this.x = x;
this.y = y;
this.minS = minS;
this.maxS = maxS;
this.w = this.h = (int)random(minS, maxS);
this.mode = mode;
c = getPixel(x,y);
}

void render()
{
c = getPixel(x,y);
if(mode == 1){
fill(c);
ellipseMode(CENTER);
ellipse(x,y,w,h);
noFill();
}else if(mode == 2){
stroke(c);
bezier(x,y,x+random(-w,w),y+random(-h,h),x+random(-w,w),y+random(-h,h),x+random(-w,w),y+random(-h,h));
noStroke();
}

}

color getPixel(int x, int y){
w = h = (int)random(minS,maxS);
return Scamera.pixels[y*width+x];
}
}
Re: pixel blocking the webcam
Reply #2 - Jun 8th, 2005, 8:02pm
 
Combining webCam pixel mofication with tiff saveFrame, and importing those frames into Flash for video presentation:

http://pixelplay.org/jeff/pro55/procPlayer.html

Code:

import processing.video.*;

float i = 1.0;
float n = 1.0;
Capture camera;


int numPixels;
int blockSize = 6;
color myMovieColors[];
void setup()

{
size(800, 600);
framerate(24);
String s = "Logitech QuickCam Zoom-WDM";
noStroke();
background(244,244,224);
camera = new Capture(this, s, 320, 240, 29);
numPixels = width / blockSize;
myMovieColors = new color[numPixels * numPixels];
}

void captureEvent(Capture camera)
{
camera.read();
for(int j=0; j<numPixels; j++) {
for(int i=0; i<numPixels; i++) {
myMovieColors[j*numPixels + i] = camera.get(i, j);
}
}
}

void draw()
{
for(int j=0; j<numPixels; j+=6) {
for(int i=0; i<numPixels; i+=6) {
color c = myMovieColors[j*numPixels + i];
fill(c);
float x = i*3;
float y = j*3;
float ranv1 = random(30)+random(-30);
float ranv2 = random(30)+random(-30);
ellipse(200+x, 100+y, ranv1, ranv2);
}
}
saveFrame("line-####.tif");
}


Page Index Toggle Pages: 1