/** press 'c' to turn the camera on and off. keep the room darkish. use your hand. it's looking for the biggest brightest blob. */ import processing.video.*; import blobDetection.*; Capture cam; BlobDetection bd; HarmonicSynth synth; PImage img; boolean newFrame=false; boolean drawBlobs=true, drawEdges=true; boolean drawCamera=false; boolean bright=true; boolean drawRadLine = false; boolean weSmooth = true; final int SEQUENCE_STEPS = 4; final static int NUM_HARMONICS = 10; double r; double lpfDivisor=16.0; float lum = 0.1; void setup() { size(640, 480); frameRate(100); cam = new Capture(this, 320, 240, 15); img = new PImage(80,60); bd = new BlobDetection(img.width, img.height); bd.setPosDiscrimination(bright); bd.setThreshold(lum); synth = new HarmonicSynth(); synth.setFrequency(300); } void captureEvent(Capture cam) { cam.read(); newFrame = true; } void draw() { if (newFrame) { newFrame = false; if(drawCamera) image(cam,0,0,width,height); else background(0); img.copy(cam, 0, 0, cam.width, cam.height, 0, 0, img.width, img.height); bd.computeBlobs(img.pixels); int bb = biggestBlob(); //drawOne(bb); drawOneAtOrigin(bb); //drawBlobsAndEdges(); } } void destroy() { synth.stop(); } void keyPressed() { switch(key) { case 'd': bright = !bright; println("bright: "+bright); bd.setPosDiscrimination(bright); break; case 'b': drawBlobs = !drawBlobs; break; case 'e': drawEdges = !drawEdges; break; case 'c': drawCamera = !drawCamera; break; case 's': weSmooth = !weSmooth; break; case 'f': println(frameRate); break; case '=': lum += 0.05; bd.setThreshold(lum); println(lum); break; case '-': lum -= 0.05; bd.setThreshold(lum); println(lum); break; case ' ': println(r); drawRadLine = true; synth.setFrequency((float) r*800); break; case '`': lpfDivisor = 1.0; println(lpfDivisor); break; case '1': lpfDivisor -= 5.0; println(lpfDivisor); break; case '2': lpfDivisor -= 1.0; println(lpfDivisor); break; case '3': lpfDivisor += 1.0; println(lpfDivisor); break; case '4': lpfDivisor += 5.0; println(lpfDivisor); break; case '5': lpfDivisor = 16.0; println(lpfDivisor); break; } }