Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

my for-loop skips a position

$
0
0

i tried to adjust a slit scan video code to move the copy command from left to right through the video. that works, but in the output it skips a position, leaving a white strip between. how can i make the output dense?

import processing.video.*;
Movie myMovie;
int pos;
int sliceSize = 5;
int outputcounter= 1;
String date;
void setup() {
  size(5000, 720);
  myMovie = new Movie(this, "versuch1.mp4");
  myMovie.loop();
  pos = 0;
  date = timestamp();
  //myMovie.jump(176);
}
void draw() {
  if (myMovie.available()) {
    myMovie.read();
    pushMatrix();
    for (int i=0; i<1280; i+= sliceSize){
    //translate(width/2, height/2);
    //rotate(HALF_PI);
    //translate(-width/2, -height/2);
    //tint(255, 20);
    copy(myMovie, i, 0, sliceSize, myMovie.height, pos, 0, sliceSize, height); //(copy (quelle, x , y, breite, höhe, position im neuen bild, ))
    scale(-1,1);
    pos+=sliceSize*i; //horizontal gefilmt
    //copy(myMovie, 0, myMovie.height/2, myMovie.width, sliceSize, 0, pos, width, sliceSize); //vertical gefilmt
    //pos-=sliceSize;
    if (pos>width) {
      saveFrame("png/"+ date+"/"+nf(outputcounter,3)+".png");
      outputcounter++;
      pos = 0;
    }
    }
    //image(myMovie, 0,0,960,540);}
    popMatrix();
  }
  }


// Called every time a new frame is available to read
/**void movieEvent(Movie m) {
 m.read();
 }*/

void keyPressed() {
  if (key == 32) {
    saveFrame("png/output_"+timestamp()+".png");
  }
}

String timestamp() {
  return new java.text.SimpleDateFormat("yyyy_MM_dd_kkmmss").format(new java.util.Date ());
}

//webseite 100vh quadrat (3/4=133) png= 001.png, 002.png

Viewing all articles
Browse latest Browse all 2896

Trending Articles