Hi everyone, I currently working on an installation with kinect and processing. Below you have a first code that I made in order to make a switch from a video to another once you cross a certain distance that the kinect will detect. I also made a fade effect go get a blur effect when you get the videoswitch to have something more soft.
The main problem in this code is that the video are constently playing on top on each other an I would prefer the video to re-play from the beggining each time that I get the video switch, do you have any idea of how I could do that ?
PS: don't pay attention to syphon, canvas etc... I only use syphon to play the video on madmapper.
Thank you :)
import< codeanticode.syphon.*; PGraphics canvas; SyphonServer server; import SimpleOpenNI.*; import java.awt.Color; import java.util.Iterator; import processing.video.*; SingleUserKinect kinect; Movie movie2, movie3 ; PVector userPosRealWorld = new PVector(); // 3d user position float comZ; // Center of Mass X int teSpelenFilmpje; boolean USE_KINECT = true; void setup() { noCursor(); // size of the window //size(400,400);// use size "(displayWidth, displayHeight)" for fullscreen size(displayWidth, displayHeight, P3D); canvas = createGraphics(displayWidth, displayHeight, P3D); server = new SyphonServer(this, "Processing Syphon"); movie3 = new Movie(this, "optic.mp4"); movie3.loop(); movie2 = new Movie(this, "OUT1.mp4"); movie2.loop(); // user SingleUserKinect for tracking. if (USE_KINECT) { kinect = new SingleUserKinect(this); } } // draw is repeatedly executed, as fast as possible, or according to frameRate setting void draw() { canvas.beginDraw(); if (USE_KINECT) { kinect.update(); } if (USE_KINECT) { if (kinect.trackedUserId != 0) { kinect.getCoM(userPosRealWorld); comZ = userPosRealWorld.z; } if (kinect.trackedUserId == 0) { comZ = -1; } } /* if (comZ>3500) { teSpelenFilmpje = 3; } else if (comZ>0) { teSpelenFilmpje = 2; } else teSpelenFilmpje=3; //niemand in beeld */ float fadewaarde = map(comZ,2000,2500,0,255); float fadeVolume = map(comZ,2000,2500,0,1); if(comZ<2000) { fadewaarde = 0; fadeVolume = 0; } if(comZ>2500){ fadewaarde =255; fadeVolume = 1; } canvas.tint(255, 255-fadewaarde); canvas.image(movie3, 0, 0, width, height); movie3.volume(1 - fadeVolume); canvas.tint(255, fadewaarde); canvas.image(movie2, 0, 0, width, height); movie2.volume(fadeVolume); canvas.endDraw(); image(canvas, 0,0); server.sendImage(canvas); } void movieEvent(Movie m) { m.read(); } // ----------------------------------------------------------------- // SimpleOpenNI user events // ----------------------------------------------------------------- // onNewUser is triggered when the kinect registers a new user void onNewUser(SimpleOpenNI curContext, int userId) { // let our SingleUserKinect Class take care of this kinect.registerNewUser(curContext, userId); } // onLostUser is triggered when the kinect deregisters a user void onLostUser(SimpleOpenNI curContext, int userId) { // let our SingleUserKinect Class take care of this kinect.deRegisterUser(curContext, userId); }