Hey Guys,
This is my code as of now.
It is indeed very slow now. I had to reduce the video capture and my display screen to somehting that is only 60 pixels in height to get acceptable performance on my Powerbook G4. Video capture also complains about not having more then one processor thread to work with.
If i switch to full screen (using library) i'm back at Dog Slow again.
Anyway - this will suffice for my aim right now: explaining and showing a very basic prototype to my teachers.
Anyhow - improvement in the code is certainly possible (altough i also read that the processing video capture library is certainly a slow one) but not my priority right now.
Thanks for all the help!
I'm sure i'll be returning soon to this developement community.
Code:
/*
Slitscan Project for Public Space @ C-MD
By Jim Bollansée
Using Code & Expertise of Olmo Claessens, Lievn Menschaert
Golan Levin and Seltar @ The Processing Forums
Some Rights Reserved 2008
*/
import processing.video.*;
Capture video;
import fullscreen.*;
FullScreen fs;
int videoSliceX;
int drawPositionX;
int windowSizeX;
int windowSizeY;
int FPS;
void setup() {
FPS = 24;
frameRate(FPS);
//video = new Capture(this, 640, 480, FPS);
video = new Capture(this, 80, 60, FPS);
//video.settings();
videoSliceX = video.width / 2;
int windowSizeX = 400;
int windowSizeY = 60;
size(windowSizeX, windowSizeY);
drawPositionX = windowSizeX-1;
background(0);
//fs = new FullScreen(this);
//fs.enter();
}
void draw() {
drawSlitScan();
shiftPixels(-1, 0);
}
void drawSlitScan ()
{
if (video.available())
{
video.read();
video.loadPixels();
loadPixels();
for (int y = 0; y < video.height; y++){
int setPixelIndex = ((height-video.height)/2+y)*width + drawPositionX;
int getPixelIndex = y*video.width + videoSliceX;
pixels[setPixelIndex] = video.pixels[getPixelIndex];
updatePixels();
}
}
}
void shiftPixels(int xOff, int yOff)
{
loadPixels();
for(int i = -xOff; i < width; i++){
for(int j = -yOff; j < height; j++){
int to = (i+xOff)+(j+yOff)*width;
int from = i+j*width;
if(to >= width*height || to < 0 || from >= width*height || from < 0){
continue;
}
pixels[to] = pixels[from];
}
}
updatePixels();
}