Friday, May 4, 2018
Processing Sketch!
As promised, here is a zip file containing the Processing sketch that I created for us to experiment with. You should change the sketch as needed and experiment (it's also on Canvas)! I've also included the code underneath the cut!
/*
Here is a sketch that uses an example called 'Scratch' to combine webcam and video.
Feel free to modify and change this sketch to suit your needs! I will add comments in
the sketch to help guide you.
*/
//this first line imports video from the sketch file
import processing.video.*;
//these are declarations that 'title' our inputs: the webcam and movie
Capture webcam;
Movie mov;
//the setup is all of the stuff that happens before the program begins running
void setup() {
//the size of this box is the size of your program's window
//it should be the same as your video size
size(1280, 720);
background(0);
//here we are initializing the webcam
webcam = new Capture(this, width, height);
webcam.start();
tint(155,255,255, 70);
loadPixels();
//this is where we load our movie
//make sure that the movie file is in the sketch folder under 'data'
//change the title beneath to match the title of your movie
mov = new Movie(this, "dance3.mov");
//Pausing the video at the first frame.
mov.play();
mov.jump(0);
mov.pause();
}
//the draw is everything that happens after the program is running
//the program will repeat the draw function in a loop while the program runs
void draw() {
//here is where we read the webcam
if (webcam.available() == true) {
webcam.read();
image(webcam,0,0);
}
//here is where we read the movie
if (mov.available()) {
mov.read();
// A new time position is calculated using the current mouse location:
float f = map(mouseX, 0, width, 0, 1);
float t = mov.duration() * f;
mov.play();
mov.jump(t);
mov.pause();
}
image(mov, 0, 0, 1280,720);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment