Introduction To Computational Media (ICM) : Week 7
Mostly Review
Movie Playback
The video library: processing.video not only contains a Capture class, it also contains a Movie class for movie playback. This class should support any movie that QuickTime supports.
A Quick Playback Example
import processing.video.*;
Movie myMovie;
void setup()
{
size(320,240);
myMovie = new Movie(this, "testmovie.mov"); // Local File, remember to "Add File"
//myMovie = new Movie(this,"http://www.wgby.org/edu/source/central/images/fish.mov"); // Network Playback
myMovie.loop();
}
void draw()
{
image(myMovie, 0, 0, width, height);
}
// Called every time a new frame is available to read
void movieEvent(Movie m)
{
myMovie.read();
}
Try it
Taking Pictures
import processing.video.*;
Capture myCapture;
PImage newImage;
void setup()
{
size(640, 240);
newImage = new PImage(320,240);
myCapture = new Capture(this, 320, 240, 15);
}
void captureEvent(Capture myCapture)
{
myCapture.read();
}
void draw()
{
image(myCapture, 0, 0);
image(newImage, 320, 0);
}
void mousePressed()
{
newImage.copy(myCapture,0,0,myCapture.width,myCapture.height,0,0,newImage.width,newImage.height);
newImage.updatePixels();
}
The important thing here is the copy function in the PImage class.