Trouble clearing Video image() with multiple clips

edited April 2015 in Kinect

Hi all.

I'm using a kinnect to built hotpoint triggers for multiple video clips. I am having major troubles figuring out how to clear the window once a new video is to be played. I have tried putting the image(videofile, 0, 0) draw function within the hotpoint trigger IF statements, but this just just leads to horrible framerate drops.

When declaring the image() just after the draw {} is called the videos run ok but I cannot figure out how to clear the screen and draw a new video on the screen without having them stacked and blocking each other everytime.

Any tips would be greatly appreciated.

code


//page 155 of make things draw
// fixed the video draw issue by not instancing backgroun in the draw loop. 
// processing seems to slow down with larger files - this could be an issue.


import processing.opengl.*;
import SimpleOpenNI.*;
import processing.video.*;
//import ddf.minim.*;
SimpleOpenNI kinect;
float rotation = 0;

Movie ExGF_Video; 
Movie FirstMemory_Video;

// declare our hotpoint objects - 

Hotpoint ExGF_Trigger; 
Hotpoint FirstMemory_Trigger;
//Hotpoint kickTrigger;
//Hotpoint hihatTrigger;
float s = 1;
void setup() {
  size(1280, 720, OPENGL);
  background (0);
  kinect = new SimpleOpenNI(this);
  kinect.enableDepth();

  //setup video file
  ExGF_Video = new Movie(this, "ExGF720.mp4");
  FirstMemory_Video = new Movie(this, "FirstMemory720.mp4");

  // initialize hotpoints with their origins (x,y,z) and their size
  ExGF_Trigger = new Hotpoint(100, 0, 600, 150); 

  FirstMemory_Trigger = new Hotpoint(-100, 0, 600, 150);
  //    
  //    hihatTrigger = new Hotpoint(300, 0, 600, 150);
}
void draw() {
  image(ExGF_Video, 0, 0);
  image(FirstMemory_Video, 0, 0);

  //background(0);
  kinect.update();


  //  translate(width/2, height/2, -1000);
  //  rotateX(radians(180));
  //  translate(0, 0, 1400);
  //  rotateY(radians(map(mouseX, 0, width, -180, 180)));
  //  translate(0, 0, s*-1000);
  //  scale(s);
  stroke(255);
  PVector[] depthPoints = kinect.depthMapRealWorld();
  for (int i = 0; i < depthPoints.length; i+=5) {
    PVector currentPoint = depthPoints[i];
    // have each hotpoint check to see if it includes the currentPoint
    ExGF_Trigger.check(currentPoint); 

    FirstMemory_Trigger.check(currentPoint);

    //      kickTrigger.check(currentPoint);
    //      
    //      hihatTrigger.check(currentPoint);
    point(currentPoint.x, currentPoint.y, currentPoint.z);
  }
  println(ExGF_Trigger.pointsIncluded); 

  if (ExGF_Trigger.isHit()) { 
    FirstMemory_Video.stop();
    ExGF_Video.play();
  }

  if (FirstMemory_Trigger.isHit()) {
    ExGF_Video.stop();
    FirstMemory_Video.play();
  }
  //  if (!snare.isPlaying()) {
  //    snare.rewind();
  //  }
  //  if (kickTrigger.isHit()) {
  //    kick.play();
  //  }
  //  if (!kick.isPlaying()) {
  //    kick.rewind();
  //  }
  //  
  //  if (hihatTrigger.isHit()) {
  //    hihat.play();
  //  }
  //  
  //  if (!hihat.isPlaying()) {
  //    hihat.rewind();
  //}

  // display each hotpoint and clear its points
  ExGF_Trigger.draw(); 

  ExGF_Trigger.clear();

  FirstMemory_Trigger.draw();

  FirstMemory_Trigger.clear();



  //  kickTrigger.draw(); 
  //
  //    kickTrigger.clear();
  //    
  //    hihatTrigger.draw();
  //    hihatTrigger.clear();
}
void stop()
{
  // make sure to close
  // both AudioPlayer objects
  //  kick.close();
  //  snare.close();
  //  hihat.close();
  //  minim.stop();
  //  super.stop();
}
void keyPressed() {
  if (keyCode == 38) {
    s = s + 0.01;
  }
  if (keyCode == 40) {
    s = s - 0.01;
  }
}

void movieEvent(Movie m) {
  m.read();
}
Sign In or Register to comment.