ICM video final timing working

I got the timing aspect of my ICM final working.

[yframe url=’http://www.youtube.com/watch?v=-fMvYiTpteg’%5D

code:

import processing.video.*;

PImage[] videoLoop;
int record = 0;
int play = 0;
boolean playing = false;

float timer = 0;

PImage oneFrame;

Capture video;
void setup() {
  size(640, 240);
  background(0);

  //println(Capture.list());

  video = new Capture(this, 320, 240);
  video.start();
  videoLoop = new PImage[0];
}

void captureEvent(Capture video) {
  //println("NEW FRAME!");
  video.read();
}

void draw() {

  image(video, 0, 0);

  if (playing) {
    play();
  }
  else {
    record();

    noStroke();
    fill(0);
    rect(video.width, 0, video.width, height);
  }

  print(record);
  print("   ");
  println(play);

  if (millis() - timer > 2000) {
    println(millis() - timer);
    timer = millis();
    play = 0;

    if (playing) {
      playing = false;
      record = 0;
    }
    else {
      playing = true;

    }
  }
}

void record() {
  videoLoop = (PImage[]) expand(videoLoop, record+1);
  videoLoop[record] = new PImage();
  videoLoop[record] = createImage(video.width, video.height, ARGB);
  videoLoop[record].loadPixels();
  for (int i = 0; i < videoLoop[record].pixels.length; i++) {
    videoLoop[record].pixels[i] = video.pixels[i];
  }
  videoLoop[record].updatePixels();
  //image(videoLoop[record], videoLoop[record].width, 0);
  record++;
}

void play() {
  play++;

  if (play < record) {
    image(videoLoop[play], width/2, 0);
  }
  //  noStroke();
  //  fill(255, 0, 0);
  //  rect(video.width, 0, video.width, height);
}
Advertisements

Author: owen ribbit

poop

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s