FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Video, Camera
(Moderator: REAS)
   Time Gradients (Serrated Images)
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Time Gradients (Serrated Images)  (Read 857 times)
TomC

WWW
Time Gradients (Serrated Images)
« on: Dec 17th, 2003, 11:57am »

NB:- self-moved/repost from 'beyond categories' following subtle renaming of this category
 
------
 
Inspired by www.serratedimage.com, I've been playing with my new webcam and I came up with these little ditties...
 
Code:

 
//
// Tom Carden - web (at) tom (dash) carden (dot) co (dot) uk
// Time  Tiles  - 5th December 2003
// Takes the central column from the webcam image and tiles it from left to right.
//
 
 
int xpos = 0;
int sliceWidth= 4;
boolean newFrame = false;
 
void setup() {  
  size(640, 480);  
  beginVideo(320, height, 30);  
}  
 
void videoEvent() {
  newFrame = true;
}
 
void loop() {  
  if(newFrame) {
    xpos += sliceWidth;
    if(xpos > width - sliceWidth) {
 //saveFrame();
 xpos = 0;  
    }
    for (int y = 0; y < height; y++) {
 for (int x = 0; x < sliceWidth; x++) {
    pixels[y*width + xpos + x] = video.pixels[y*video.width + video.width/2 + x];
 }
    }
    newFrame = false;
  }  
}  
 

 
The first one looks good with size(screenWidth,480).  Anyone know if there's a way to avoid hardcoding the screensize in processing?  Is there a screen size constant somewhere?
 
Code:

 
//
// Tom Carden - web (at) tom (dash) carden (dot) co (dot) uk
// Time Gradient  - 5th December 2003
// Delaying video across the screen (left hand side is 10 seconds older than right hand side).
// NB - needs stacks of RAM and a Webcam.
//
 
int currentLine = 0;
BImage[] buffer;
 
void setup() {  
  size(320,240); // the most my 512MB laptop will cope with!
  beginVideo(width, height, 30);
  buffer = new BImage[width]; // a buffer for each column of pixels
  for (int j = 0; j < buffer.length; j++) {
    buffer[j] = new BImage(width-j, height); // remember "width" (e.g. 320) columns for the left hand side, and 1 for the right hand side
  }
}  
 
void loop() {  
    for (int x = 0; x < width; x++) {
 for (int y = 0; y < height; y++) {
   buffer[x].pixels[(currentLine % buffer[x].width) + (y * buffer[x].width)] = video.pixels[x + (y * video.width)]; // record each column of pixels in new column of buffer
   pixels[(y * width) + x] = buffer[x].pixels[(y * buffer[x].width) + ((currentLine + 1) % buffer[x].width)]; // draw the oldest column (1 before the one we just remembered)
 }
    }
    currentLine++;
}
 

 
If anyone has a powerful enough machine (ie enough RAM) to run the second one high-res, I'd be interested in seeing it.  Any hints on optimisation would be greatfully received.  I think it needs width * (width/2 * height) pixels storing, which if BImage is 32bit will mean e.g. ~100MB for 320x240 but ~750MB for 640x480.  Am I right?  Can BImage (or an alternative) use compression on the fly (and how quickly can images be compressed and uncompressed to memory?).
 
 
flight404

WWW Email
Re: Time Gradients (Serrated Images)
« Reply #1 on: Dec 17th, 2003, 3:38pm »

I am rather fond of the second execution.  Very underwater-trippy.  Thought I had more RAM than I obviously do because I couldnt do more than 320x240 as well.
 
r
 
Jerronimo

WWW
Re: Time Gradients (Serrated Images)
« Reply #2 on: Dec 17th, 2003, 8:28pm »

The second one is awesome!
 
 
The first one reminds me of my linear strip sketches (first two in the bottom section of this page: http://www.cis.rit.edu/~jerry/Software/p5/ )
 
Neat stuff!
« Last Edit: Dec 18th, 2003, 5:58am by Jerronimo »  
Andrew

WWW
Re: Time Gradients (Serrated Images)
« Reply #3 on: Dec 18th, 2003, 1:15am »

yes the second one is quite strange.  I love it
 
charmhaste
Guest
Email
Re: Time Gradients (Serrated Images)
« Reply #4 on: Apr 11th, 2004, 7:41am »

I also dig teh second one
 
Pages: 1 

« Previous topic | Next topic »