// Project for Processing Exhibition, July 05 by: // Ana Kronschnabl and Mike Tonks, Fluffy Logic Ltd. // Fading images layered over looped video and sound clips. // Pixelation & distortion effect controlled by video capture movement sensor. // Fading of video and volume of sound clip linked to movement control. import processing.video.*; import pitaru.sonia_v2_9.*; Movie myMovie; Sample myAudio; int videoAlpha = 200; int videoClarity = 200; float audioVol = 1; int myPixelation = 1; int myMasterLevel = 0; int mySecond = second(); //number of images - change this value with every image you add to the data folder int numOfImages = 28; int imgArraySize = 6; int fadeSpeed = 3; //tracks the current number of objects created int currentObjectIndex = 0; int maxObjectIndex = 0; //image array PImage[] _image = new PImage[imgArraySize + 1]; //stores the actual filename of images os you are able to load them dynamically String[] listOfImages = new String[imgArraySize + 1]; //list of Image objects Image[] imageOnScreen= new Image[imgArraySize + 1]; // Init camera for movement sensor Capture camera; float frameCount = 0; float[] oldValues; // Set this value between say 50000 and 250000 to adjust the movement sensiticity int movementCalibration = 50000; int captureGridSize = 10; int capturePixelScaling = 4; int imgSecondDelay = 5; void setup(){ size(640, 480); background(0); // Load and play the video in a loop myMovie = new Movie(this, "virg_loopno.mov"); myMovie.loop(); // Audio stuff Sonia.start(this); // Start Sonia engine. myAudio = new Sample("virginia_loop.wav"); myAudio.repeat(); // List all available capture devices to the console // Use the information printed to the text area to // correctly set the variable "s" below println("Detecting Video Capture Devices: " + Capture.list() ); // Specify your own device by the name of the capture // device returned from the Capture.list() function // String s = "Logitech QuickCam Zoom-WDM"; // camera = new Capture(this, s, width, height, 30); // If no device is specified, will just use the default camera = new Capture(this, 640, 480, 2); //camera = new Capture(this, 320, 20, 1); // Opens the settings page for this capture device //camera.settings(); loadPixels(); oldValues = new float[camera.width * camera.height / captureGridSize / captureGridSize]; for(int i=1; i 255) { varChange = 255; } //println ("Total Change [ frame " + frameCount + " ] : " + totalChange + " [ " + movementCalibration + " ] - " + varChange); //println (""); setMasterLevel(varChange); } void displayImage(){ //if the variable currentObjectIndex exceeds the number of images we have then reset to zero... if (currentObjectIndex > imgArraySize - 1){ currentObjectIndex = 0; } //... otherwise add one to the current value of currentObjectIndex currentObjectIndex++; // Keep the maxImage so that once we've gone around, we only delete one image each time, not all. if (currentObjectIndex > maxObjectIndex) { maxObjectIndex = currentObjectIndex; } int myImageNo = int(random(1, 28)); //create a new reference to the image storing the image in the array listOfImages //NOTE: rather than pointing to an image file on your desktop it could also be an image file on the server //you just need to specify the path to the file listOfImages[currentObjectIndex] = "image"+myImageNo+".jpg"; //load the image _image[currentObjectIndex] = loadImage(listOfImages[currentObjectIndex]); // Generate a random position on the screen int imgX = int(random(50, 500)); int imgY = int(random(50, 380)); //create a new object sending the co-ordinate and tint values to the Image constructor imageOnScreen[currentObjectIndex] = new Image(_image[currentObjectIndex],imgX,imgY, 200,150, int(random(50,150) - (myPixelation * 4) )); //imageOnScreen[currentObjectIndex] = new Image(_image[currentObjectIndex],imgX,imgY, 200,150, int(random(100,220))); //call the function display() imageOnScreen[currentObjectIndex].display(); } class Image{ //class properties PImage imageName; float x; float y; float _width; float _height; int _alpha; int pixelation; //class constructor Image(PImage _imageName, float _x, float _y, float _w, float _h, int alph){ imageName = _imageName; x = _x; y = _y; _width = _w; _height = _h; _alpha = alph; pixelation = 1; } //class functionality void display(){ tint(255, _alpha); image(imageName,x,y); if (myPixelation > 1) { image_pixelate(int(x), int(y), imageName.width, imageName.height); } // if (pixelation <= 1) { // image(imageName,x,y); // } else { // image_pixelate(); // } //uncomment the following to apply blur //filter(BLUR, imageBlur); } } void fade(){ // background(0); //println ("Fade: ..."); for (int i = 1; i <= maxObjectIndex; i=i+1) { imageOnScreen[i]._alpha = imageOnScreen[i]._alpha - fadeSpeed; imageOnScreen[i].display(); } } void image_pixelate(int x, int y, int w, int h){ color myPixel = color(0,0,0); loadPixels(); for (int j=0; j<=h; j++){ if (y+j < height) { for (int i=0; i<=w; i=i+2) { if (x+i < width) { if (i % myPixelation == 0 || j % myPixelation == 0) { myPixel = pixels[(y+j)*width+i+x]; } pixels[(y+j)*width+i+x] = myPixel; pixels[(y+j)*width+i+x-1] = myPixel; } } } } updatePixels(); } void video_pixelate(){ color myPixel = color(0,0,0); loadPixels(); for (int i=0; i<(width*height)-width; i++) { if (i % 100 == 0) { myPixel = pixels[i]; } pixels[i] = myPixel; } updatePixels(); } void setMasterLevel(int level) { // Using the passed movement level, change the controllers in an appropriate way. if (level > 30 ) { videoAlpha += level / 2; if (videoAlpha > 300) { videoAlpha = 300; } } else { // videoAlpha -= (videoAlpha - level) / 2; videoAlpha -= 20; if (videoAlpha < 1) { videoAlpha = 1; } } videoClarity = videoAlpha; audioVol = float( videoAlpha ) / 255; if (audioVol > 1) {audioVol = 1; } myAudio.setVolume(audioVol); //println ("setMasterLevel - videoAlpha: " + videoAlpha); //println ("setMasterLevel - audioVol: " + audioVol); //videoAlpha = level; //videoClarity = level; myPixelation = videoAlpha / 20; if (myPixelation < 0) { myPixelation = 0; } //println ("setMasterLevel - myPixelation: " + myPixelation); }