fierceosity
YaBB Newbies
Offline
Posts: 3
Video output + JMyron Input
Oct 15th , 2008, 9:29am
So I'm trying to run this code that plays tiled strips of video simultaneously to create a ripple effect on digital wallpaper. My code works - but it's mind numbingly slow. Any ideas to speed it up? Do i need to step on the quality of my video? Here's what i've been running: <quote> //import motiontracking, video, fullscreen libraries import JMyron.*; import processing.video.*; import fullscreen.*; JMyron look;//a camera object FullScreen fs; //fulscreen object //variables to maintain the floating green circle float objx = 0; float objy = 0; float objdestx = 0; float objdesty = 0; //Wallpaper Dimensions int movieWidth=128; int movieHeight=576; int movieStart=105; //leaves white letterbox to maintain 16:9 ratio int strips=8; //Wallpaper Files Movie movieR_A; Movie movieR_Ba; Movie movieR_Bb; Movie movieR_Ca; Movie movieR_Cb; Movie movieL_A; Movie movieL_Ba; Movie movieL_Bb; Movie movieL_Ca; Movie movieL_Cb; Movie movieREG; void setup() { //FULLSCREEN SETUP size(1024, 786); // set size to 1024X786 frameRate(24); // 24 fps fs = new FullScreen(this); // Create the fullscreen object fs.enter(); // enter fullscreen mode //VIDEO TRACKING SETUP look = new JMyron();//make a new instance of the object look.start(width,height); look.trackColor(255,255,255,256*3-100);//track white look.update(); look.adaptivity(1); look.adapt();// immediately take a snapshot of the background for differencing rectMode(CENTER); noStroke(); //VIDEO PLAYBACK SETUP background(255); size(1024, 786); movieR_A = new Movie(this, "R_A.mov"); movieR_Ba = new Movie(this, "R_Ba.mov"); movieR_Bb = new Movie(this, "R_Bb.mov"); movieR_Ca = new Movie(this, "R_Ca.mov"); movieR_Cb = new Movie(this, "R_Cb.mov"); movieL_A = new Movie(this, "L_A.mov"); movieL_Ba = new Movie(this, "L_Ba.mov"); movieL_Bb = new Movie(this, "L_Bb.mov"); movieL_Ca = new Movie(this, "L_Ca.mov"); movieL_Cb = new Movie(this, "L_Cb.mov"); movieREG = new Movie(this, "REG.mov"); } void draw() { //tiles background video strips for(int i=0; i<=strips; i++){ image(movieREG, movieWidth*i,movieStart,movieWidth,movieHeight);} movieREG.loop(); movieREG.play(); //motion tracking look.update();//update the camera view int[][] centers = look.globCenters();//get the center points //calculating the average. float avX=0; float avY=0; for(int i=0;i<centers.length;i++){ avX += centers[i][0]; avY += centers[i][1]; } if(centers.length-1>0){ avX/=centers.length-1; avY/=centers.length-1; } //update the location of the thing if(!(avX==0&&avY==0)&¢ers.length>0){ objdestx = avX; objdesty = avY; } objx += (objdestx-objx)/10.0f; objy += (objdesty-objy)/10.0f; //prints xy value of camera mouse // print("X is "+objx); // print(" AND "); // println("Y is "+objy); testMouse(avX, avY); } void testMouse(float avX, float avY){ if(avY<=393){ int x=(int)(avX/128); cascadeR(x); } if(avY>=393){ int x=(int)(avX/128); cascadeL(x); } } void cascadeR(int num){ image(movieR_A, movieWidth*(num),movieStart,movieWidth,movieHeight); image(movieR_Ba, movieWidth*(num+1),movieStart,movieWidth,movieHeight); image(movieR_Bb, movieWidth*(num-1),movieStart,movieWidth,movieHeight); image(movieR_Ca, movieWidth*(num+1),movieStart,movieWidth,movieHeight); image(movieR_Cb, movieWidth*(num-1),movieStart,movieWidth,movieHeight); movieR_A.loop(); movieR_Ba.loop(); movieR_Bb.loop(); movieR_Ca.loop(); movieR_Cb.loop(); /* movieR_A.play(); movieR_Ba.play(); movieR_Bb.play(); movieR_Ca.play(); movieR_Cb.play(); */ } void cascadeL(int num){ image(movieL_A, movieWidth*(num),movieStart,movieWidth,movieHeight); image(movieL_Ba, movieWidth*(num+1),movieStart,movieWidth,movieHeight); image(movieL_Bb, movieWidth*(num-1),movieStart,movieWidth,movieHeight); image(movieL_Ca, movieWidth*(num+1),movieStart,movieWidth,movieHeight); image(movieL_Cb, movieWidth*(num-1),movieStart,movieWidth,movieHeight); movieL_A.loop(); movieL_Ba.loop(); movieL_Bb.loop(); movieL_Ca.loop(); movieL_Cb.loop(); /* movieL_A.play(); movieL_Ba.play(); movieL_Bb.play(); movieL_Ca.play(); movieL_Cb.play(); */ } // Called every time a new frame is available to read void movieEvent(Movie m) { m.read(); } public void stop(){ look.stop();//stop the object super.stop(); } </quote>