Tuesday

Movie Magic!!!

For a little while I concentrated on the Movie example in OpenCv:

Name movie()
Examples
movie
import hypermedia.video.*;


OpenCV opencv;

void setup() {
  size( 640, 480 );
  opencv = new OpenCV( this );
  opencv.movie( "bunny.avi", width, height );    // load movie file
}

void draw() {
  opencv.read();                  // read a new frame
  image( opencv.image(), 0, 0 );  // and display image
}

void mousePressed() {
  float time = mouseX/float(width);
  opencv.jump( time );            // jump to a specified frame
}


This was interesting to me especially after seeing some of the installations from the monster media website, such as the following:




 

A lot of them follow the idea of detecting motion, which then activates a video clip or animation to play. I though this could be very exciting.

A busily researched online, and especially on Processing fourms, as to an idea of how to achieve this. I only wanted my installation to play a simply movie, created in After effects, when movement was detected.
I looked into practical ideas such as when movement was detected in a certain coordinate of the stage, it would activate the movie clip.I also looked into when movement was detected in terms of changes of light it would do the same thing. Could I find any help? NOOOOOOOOOOOOOO!!!

 I tried to place parts of code from various sources together to achieve the effect I wanted.

I firstly started by placing the code from the Movie example and the Blob detection.

Code:

import hypermedia.video.*;
import java.awt.*;
OpenCV opencv;

int w = 320;
int h = 240;
int threshold = 80;

boolean find=true;
PFont font;

void setup() {

  size( 640, 480 );

  opencv = new OpenCV( this );
    opencv.capture(w,h);
  opencv.movie( "bunny.avi", width, height );
 
    font = loadFont( "AndaleMono.vlw" );
    textFont( font );

  println( "Click inside sketch window to change movie timecode" );
  println( "Press space bar to record background image" );
 
}

void draw() {
background(0);
  opencv.read();
  //if ( remember ) opencv.absDiff();
  //sopencv.threshold( 200 );

  image( opencv.image(), 0, 0 );
   image( opencv.image(OpenCV.GRAY), 20+w, 10 );   // GRAY image
    image( opencv.image(OpenCV.MEMORY), 10, 20+h ); // image in memory

 opencv.absDiff();
    opencv.threshold(threshold);
    image( opencv.image(OpenCV.GRAY), 20+w, 20+h ); // absolute difference image

}

/*void keyPressed() {
  opencv.remember();
  remember = true;
}
*/
void mousePressed() {
  float time = mouseX/float(width);
  opencv.jump( time );

}

and result:



Pants! It detects the movies blobs rather than my webcam!!! I'm not sure how to get around this.
I will keep experimenting, although I want to look at other effects too and something might outshine!!!
I will also keep looking at my two main inspirations for this project: Nike Jumpman and Monster media. They will help me!

0 comments:

Post a Comment