We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Draw on top of a Movie?? (Read 3040 times)
Draw on top of a Movie??
Dec 15th, 2007, 12:10am
 
I'm using ReacTIvision to detect objects moving around in front of the Webcam. I'm a bit fresh on these thing so I'm not sure this is possible. I am a graphic design, with very little experience in programming. Basically I'm importing a movie and using the objects tracking from ReacTIVision, I need to draw over this movie. I tryed to draw over a video Capture and it worked. But I cant get it to work with an imported movie (.mov) the drawing seems to not cover the movie. Is it impossible to draw over a movie??
Re: Draw on top of a Movie??
Reply #1 - Jan 9th, 2008, 4:41am
 
Hey, guys, this is a fairly simple question, could someone answer this? I'm quite curious.

Good idea, by the way.
Re: Draw on top of a Movie??
Reply #2 - Jan 9th, 2008, 8:54am
 
there's no problem with drawing on top of movies, they are handles as images:

/**
* Processing loop example
*/

import processing.video.*;

Movie myMovie;


void setup()
{
 size(640, 480);
 myMovie = new Movie(this, "station.mov");
 myMovie.loop();
}


void movieEvent(Movie myMovie)
{
 myMovie.read();
}


void draw()
{
 background(0);
 image(myMovie, 0,0, width, height);
 rect( 100, 100, width-200, height-200 ); // draw rect above movie ..
}

F
Re: Draw on top of a Movie??
Reply #3 - Jan 9th, 2008, 10:59am
 
Thanks Fjen,

But this is not drawing over a movie. Your example only places a rectangle over the movie. If I want a drawing efect over it, it will not work. I tryed putting the coordenates of the mouse to the rectangle as to make a drawing efect and it only makes the rectangle follow the mouse. it will not draw "white rectangles" over the movie.

Maybe I wasnt clear. What I really wanted to do is to "erase" the movie with a "white" drawing efect, turning the whole screen to White as I pass the mouse over it on every strike.
H
Re: Draw on top of a Movie??
Reply #4 - Jan 9th, 2008, 2:42pm
 
Then...
  • CreateGraphics() the "upper layer"
  • _NEVER_ call background() on the upper layer, that way successive draws stay on it.
  • Every "redraw", image first the movie, and then the created graphics' .get() to overlay it.

    hmm... how to preserve transparency <_<

    nevermind, still interesting.
  • Re: Draw on top of a Movie??
    Reply #5 - Jan 9th, 2008, 3:19pm
     
    in other words:
    Code:

    import processing.video.*;

    Movie myMovie;

    PGraphics topLayer;

    void setup()
    {
    size(640, 480);
    myMovie = new Movie(this, "station.mov");
    myMovie.loop();
    topLayer = createGraphics(width, height, g.getClass().getName());
    }


    void movieEvent(Movie myMovie)
    {
    myMovie.read();
    }

    void draw()
    {
    image(myMovie, 0,0, width, height);
    topLayer.beginDraw();
    topLayer.noFill();
    topLayer.stroke( 255 );
    topLayer.line( pmouseX, pmouseY, mouseX, mouseY );
    topLayer.endDraw();
    image( topLayer, 0, 0 );
    }


    F
    Re: Draw on top of a Movie??
    Reply #6 - Jan 9th, 2008, 5:13pm
     
    Thanks Fjen!

    Thats exactly the code sequence I needed. I used a rectangle as a drawing tool instead of a line, but the rest is the same. Great help.
    Hope I can now get the curser coordenate from the ReacTIvision so I can draw on the movie using Object tracking from a webcam...
    Re: Draw on top of a Movie??
    Reply #7 - Feb 1st, 2009, 7:54pm
     
    Much appreciated Fjen!

    I modified your code to enable an alpha masked QuickTime to play on top of a live camera feed and it works a treat (playback is great).

    Alot of other options seemed to bring in a fair bit of lag on playback (especially if trying to manipulate tints, etc)


    Code:

    import processing.video.*;  
     
    Capture inputCam01;

    Movie topLayer;

    void setup()  
    {  
     size(640, 480);  
     frameRate(25);
     
     // Declare camera capture
     inputCam01 = new Capture(this, 640, 480);
     
     // Declare movie playback and "knock out" alpha channel
     topLayer = new Movie(this, "QuickTime_with_alpha.mov");
     topLayer.loop();
     topLayer.mask(topLayer);
    }  
     
     
    void movieEvent(Movie topLayer)  
    {  
    topLayer.read();
    }
     
    void draw()  
    {  
     if (inputCam01.available() == true) {
       inputCam01.read();
       image(inputCam01, 0, 0);
     }
     
     image(topLayer, 0, 0);
     topLayer.mask(topLayer);
    }

    Re: Draw on top of a Movie??
    Reply #8 - Mar 25th, 2009, 6:44am
     
    Hey thanks a lot fjen, this has helped out a lot.

    I was also just wandering if it is easy to mask part of a movie (given certain data points for a rect) to reveal another movie (which reveals the same area for that movie).

    thanks for any and all help.
    Page Index Toggle Pages: 1