/** * * Doing some stuff with video. */ import hypermedia.video.*; import java.awt.Rectangle; import de.bezier.data.sql.*; import java.util.Collections; import java.util.Random; import processing.video.*; Movie myMovie; Gaggle agents; // ---- face tracking stuff ---- // last recognized data int x_pos = 0; int y_pos = 0; int w_face = 0; int h_face = 0; // to store face recognition data int MAX = 10; int[] x = new int[MAX]; int[] y = new int[MAX]; int[] w = new int[MAX]; int[] h = new int[MAX]; PImage img; PImage frameimg; // SQL stuff MySQL msql; PFont font; // what table and what column to query in db // this determines what data is played back String table = "media"; String ftable = "videofaces"; String column = "name"; // vars holding response most recent query String data= ""; String path=""; String fname=""; String filetype=""; int filenum=257; int facenum=0; int frame=0; int id=0; float moviepos=519.8; float lasttime=0; boolean newframe=false; // ---- interactivity ---- // // timing int last=0; boolean paused=false; void setup() { //size(1280, 720, P2D); size(screen.width, screen.height); background(0); strokeWeight(2); noFill(); // Font and text drawing setup font = loadFont("HelveticaNeue-48.vlw"); textAlign(LEFT); // textAlign(CENTER,CENTER); rectMode(CORNER); fill(255); textFont(font, 24); // Load and play the video in a loop myMovie = new Movie(this, "/Volumes/Reservoir/Assets/Video/twomeymovie/Untitled10.mov"); myMovie.loop(); myMovie.read(); myMovie.jump(moviepos); myMovie.speed(0.07); // debug println(myMovie.width); println(myMovie.height); agents = new Gaggle(this, myMovie.width, myMovie.height ); last=-1000; //initializeAvg(); } void doFaceTracking() { frame++; myMovie.loadPixels(); frameimg = new PImage(myMovie.width, myMovie.height, RGB); arraycopy(myMovie.pixels, frameimg.pixels); frameimg.updatePixels(); int count = agents.checkframe(frameimg); if(count>0) { println("time: "+str(myMovie.time())+", "+count+" faces"); } else { println(" no faces in frame."); } } void movieEvent(Movie myMovie) { if(!paused) { lasttime=myMovie.time(); myMovie.read(); newframe=true; } } void draw() { if((!paused)) { // erase image and put curr video frame if(newframe) { background(0); image(myMovie, 0, 0); fill(64, 64, 64); text(myMovie.time()+" s\n"+myMovie.duration()+" total \n"+(myMovie.time()-lasttime)+" dt", 50, myMovie.height+50); noFill(); doFaceTracking(); newframe=false; } agents.relax(); } } void saveSnapShot() { //myMovie.save(savePath("/Users/rtwomey/Desktop/images/"+vidName)); save("snapshot_"+str(myMovie.time())); } void saveFace() { // PImage face = frameimg.get(round(ax), round(ay), round(aw), round(ah)); // face.save(savePath("/Users/rtwomey/Desktop/twomey family movie/Untitled10_"+str(myMovie.time()))); } void mousePressed() { myMovie.jump(float(mouseX)/float(width)*myMovie.duration()); } void keyPressed() { if(key==' ') paused = (paused == true) ? false : true; if(key=='s') saveSnapShot(); } public void stop() { agents.stop(); super.stop(); }