// Mirror images processing // Reflection reMapping // // ideas // . using movie for site instead, switch between analitical and mirror mode // . time the effect presentation like, basic image, mirrors, analysis, display, and again // this text goes out to html /** press d to display an image * press f to flatten the mirrors press i to swap background * press l to swap content */ // setup webCam input //~ import processing.video.*; //~ Capture myCapture; // image variables PImage streetImage; PImage displayImage; PImage canvasImage=new PImage(400,300); int[] imagePixels; int imageWidth = 400; int imageHeight = 300; int imagePixelAmount = imageWidth * imageHeight; int streetImageSetSize = 6; // amont of available images as backgrounds int currentStreetImage = 0; // counter for loading the above int contentImageSetSize = 5; // amont of available images to display int currentContentImage = 0; // counter for loading the above // displayImage int displayImageWidth = 40; // init segments (mirrors) int mirrorWidth = 10; // has to be while divideable with imageWidth int mirrorHeight = 10; // hes to be whole divideable with imageHeigth float[][] coloumnBrigthness; //for storing mirror average brightness, 0-100 float[][] coloumnHue; //for storing mirror average hue, 0-100 int mirrorView[][]; // where a coloumn / row mirror is looking at, defining its angle, and image offset int mirrorFlatView[][]; // where a coloumn / row mirror is looking at if reset to zero offset float[] rowBrigthness; // for storing mirror average color float[][] targetBrightness; // for storing the image brigthness we want to display, 0-100 float[][] targetHue; // for storing the image hue we want to display, 0-100 float rotationSpeed = 5; // flags int coloumn = 0; int row = 0; int flag = 0; boolean runOnce = false; boolean analysis = false; boolean showDisplay = false; boolean showFlat = true; // setup global options void setup(){ size(400, 300); colorMode(HSB, 100); framerate(25); // to find out your camera name, uncomment the following line // println(Capture.list()); //~ String webCamName = "Labtec WebCam-WDM"; //~ myCapture = new Capture(this, webCamName, width, height, 30); } // looping main void draw(){ if (!runOnce){ initArrays(); initImage(); loadDisplayImage(); runOnce = true; } //~ initImage(); if (analysis){ //drawAnalisys(); } else { rotateMirrors(); drawMirrors(); } drawGrid(); //saveFrame("alephvideomirror-#####.tif"); } // get background image void initImage(){ streetImage = loadImage("testimage"+currentStreetImage+".jpg"); if (currentStreetImage < streetImageSetSize - 1){ currentStreetImage++; } else { currentStreetImage = 0; } //myCapture.read(); //streetImage = myCapture; for(int i=0; i rotationSpeed){ mirrorView[coloumn][row] -= int((mirrorView[coloumn][row] - hitPosition)/rotationSpeed); } else { mirrorView[coloumn][row] = hitPosition; } } else if (showFlat) { if (abs(mirrorView[coloumn][row] - mirrorFlatView[coloumn][row]) > rotationSpeed){ mirrorView[coloumn][row] -= int((mirrorView[coloumn][row] - mirrorFlatView[coloumn][row])/ rotationSpeed); } else { mirrorView[coloumn][row] = mirrorFlatView[coloumn][row]; } } } } }; // draw Mirrors void drawMirrors(){ //loadPixels(); /* for(int i=0; i