Hi
I am very new to this but find processing a fun and experimental experience. I am currently interested in the slit scan processing by Golan Levin.
I have been spending hours trying to figure out how to change the direction of the scan to go from left to right in larger sections rather than little slivers of imagery from the webcam.
I have tried to change this part to capture larger sections from the video camera to be displayed but no luck so far:
videoSliceX = video.width / 2;
I think this part may be the start position of the shown images?
drawPositionX = width - 1;
From some trial and error I think have narrowed the area that needs to be changed for the position to be continuously drawn:
for (int y = 0; y < video.height; y++){
int setPixelIndex = y*width + drawPositionX;
int getPixelIndex = y*video.width + videoSliceX;
pixels[setPixelIndex] = video.pixels[getPixelIndex];
}
I have been researching and trying to understand these variables and codes from the processing.org tutorials and example part of the website, but there are still some things I don't understand like the coding "width - 1" or "height - 1"- it seems to indent from the right or top if the numbers are changed, but if it is changed to +, the program won't work.
I am a real beginner and very inexperienced and would greatly appreciate any help/support here as my own attempts with code modification won't work and I really want to start learning about processing in a more accurately informed manner.
Thank you for your time!
Here is the code I have been looking at:
/**
* 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.
*/
import processing.video.*;
Capture video;
int videoSliceX;
int drawPositionX;
void setup() {
size(600, 240, P2D);
// Uses the default video input, see the reference if this causes an error
video = new Capture(this, 320, 240);
video.start();
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--;
// Wrap the position back to the beginning if necessary.
if (drawPositionX < 0) {
drawPositionX = width - 1;
}
}
}