Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
[PROCESSING - KEYSTONE] : Multiple Video Corner Pin
import deadpixel.keystone.*;
import processing.video.*;
Keystone ks;
CornerPinSurface surface;
PGraphics offscreen;
CornerPinSurface surface1;
PGraphics offscreen1;
Movie movie;
void setup() {
// Keystone will only work with P3D or OPENGL renderers,
// since it relies on texture mapping to deform
size(1600, 1200, P3D);
ks = new Keystone(this);
surface = ks.createCornerPinSurface(320, 240, 20);
surface1 = ks.createCornerPinSurface(320, 240, 20);
surface1.moveTo(400, 0);
offscreen = createGraphics(320, 240, P2D);
offscreen1 = createGraphics(320, 240, P2D);
// Load and play the video in a loop
movie = new Movie(this, "cat.mov");
movie.loop();
}
void draw() {
// Draw the scene, offscreen
offscreen.beginDraw();
offscreen.background(255);
offscreen.image(movie, 0, 0, 320, 240);
offscreen.endDraw();
offscreen1.beginDraw();
offscreen1.background(255);
offscreen1.image(movie, 0, 0, 320, 240);
offscreen1.endDraw();
// most likely, you'll want a black background to minimize
// bleeding around your projection area
background(0);
// render the scene, transformed using the corner pin surface
surface.render(offscreen);
surface1.render(offscreen);
}
void keyPressed() {
switch(key) {
case 'c':
// enter/leave calibration mode, where surfaces can be warped
// and moved
ks.toggleCalibration();
break;
case 'l':
// loads the saved layout
ks.load();
break;
case 's':
// saves the layout
ks.save();
break;
}
}
void movieEvent(Movie m) {
m.read();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment