Loading...
Logo
Processing Forum
/**
* Simple Real-Time Slit-Scan Program.
* By Golan Levin.
*
* This demonstration depends on the canvas height being equal
* to the video capture height. If you would prefer otherwise,
* consider using the image copy() function rather than the
* direct pixel-accessing approach I have used here.
*
* Created December 2006.
* Updated September 2011 by James Hale.
*/
import processing.video.*;

Capture video;

int videoSliceX;
int drawPositionX;

void setup() {
size(1000, 480, P2D);

// Uses the default video input, see the reference if this causes an error
video = new Capture(this, 1000, 480, 30);

videoSliceX = video.width / 2;
drawPositionX = width - 1;
background(0);
}

void draw() {
if (video.available()) {
video.read();
video.loadPixels();

// Copy a column of pixels from the middle of the video
// To a location moving slowly across the canvas.
loadPixels();
for (int y = 0; y < video.height; y++){
int setPixelIndex = y*width + drawPositionX;
int getPixelIndex = y*video.width + videoSliceX;
pixels[setPixelIndex] = video.pixels[getPixelIndex];
}
updatePixels();

drawPositionX--;

// Saves your image if pixels reach the end of the frame
if (drawPositionX < 0) {
saveFrame();
drawPositionX = width - 1; 
}
// Takes another photo if you click the mouse.
if(mousePressed) {
drawPositionX = width - 1;}
}
}

this is a slitscan program i updated to save images and restart the photo by clicking

I have been working on and researching all day how to get Movie movie to break down into pixels then load pixels the same way as a slit scan, so i could use a movie file rather than the built in camera on my computer.

Does anyone knows what i need to change to call the movie in and get it to only display the center pixels

Thank you very much

Replies(3)

Check out the example pixelate.

Copy code
  1.  Movie movie;

  2. void setup(){
  3. movie = new Movie(this, "YOURFILE.mov");
  4. }
  5. void draw(){
  6. movie.read();
  7. movie.loadPixels();
  8. }
Should call the movie in. Load the pixels the same way as your webcam capture. As for the center do this:
Copy code
for (int y = (video.height - YOURDEFOFCENTRE);  y < (video.height + YOURDEFOFCENTRE); y++){
int setPixelIndex = y*width + drawPositionX;
int getPixelIndex = y*video.width + videoSliceX;
pixels[setPixelIndex] = video.pixels[getPixelIndex];
}

/**
* Simple Real-Time Slit-Scan Program.
* By Golan Levin.
*
* This demonstration depends on the canvas height being equal
* to the video capture height. If you would prefer otherwise,
* consider using the image copy() function rather than the
* direct pixel-accessing approach I have used here.
*
* Created December 2006.
* Updated September 2011 by James Hale.
*/

//calling video 
import processing.video.*;

//variables
Movie video;

int videoSliceX;
int drawPositionX;


//SET UP//////////////////////////
void setup() {
size(1000, 480, P2D);

// Uses the default video input, see the reference if this causes an error
video = new Movie(this, "doesthiswork.mov");




//What part of the image
videoSliceX = video.width / 2;
drawPositionX = width - 1;
background(0);
}

//DRAW/////////////////////

void draw() {
video.read();
video.loadPixels();

// Copy a column of pixels from the middle of the video
// To a location moving slowly across the canvas.

for (int y = 0; y < video.height; y++){
int setPixelIndex = y*width + drawPositionX;
int getPixelIndex = y*video.width + videoSliceX;
pixels[setPixelIndex] = video.pixels[getPixelIndex];
}
updatePixels();

drawPositionX--;

// Saves your image if pixels reach the end of the frame
if (drawPositionX < 0) {
saveFrame();
drawPositionX = width - 1; // not sure this works
}
// Takes another photo if you click the mouse.
if(mousePressed) {
drawPositionX = width - 1;}
}


still not working, it errors at pixels[setPixelIndex] = video.pixels[getPixelIndex];

describe the error i.e what java is saying.
hint: did you declare pixels
int pixels[video.width*video.height];