// Pretty basic code, here. Not sure how much of it is still working. // This should use the Microsoft Kinect as a face-tracking theremin, // generating noise based on the position of the first three faces // found in the video frame. import org.openkinect.*; import org.openkinect.processing.*; import hypermedia.video.*; import ddf.minim.*; import ddf.minim.signals.*; import java.awt.Rectangle; Kinect kinect; OpenCV opencv; Minim minim; AudioOutput aout; boolean depth = true; boolean rgb = true; boolean ir = false; int vibrato_rate = 15; int vibrato_cap = 100; int vibrato = 0; ArrayList sines = new ArrayList(); float deg = 15; // Start at 15 degrees void setup() { size(640,520); kinect = new Kinect(this); kinect.start(); kinect.enableDepth(depth); kinect.enableRGB(rgb); kinect.enableIR(ir); kinect.tilt(deg); opencv = new OpenCV( this ); opencv.capture(640, 480); opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); minim = new Minim(this); aout = minim.getLineOut(Minim.MONO); for (int i = 0; i < 3; i++) { SineWave s = new SineWave(440, 0.5, aout.sampleRate()); s.portamento(200); sines.add(s); aout.addSignal(s); } } void draw() { background(0); PImage rgbImg = kinect.getVideoImage(); PImage zImg = kinect.getDepthImage(); opencv.copy(rgbImg); opencv.convert( GRAY ); Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 ); image(rgbImg, 0, 0); // draw face area(s) noFill(); stroke(255,0,0); for( int i=0; i vibrato_cap) vibrato_rate *= -1; vibrato += vibrato_rate; return freq + vibrato; } void changeVibratoMax(Rectangle[] faces, int sampleSize) { vibrato_cap = 0; for (int i = 0; i < sampleSize; i++) { vibrato_cap += (faces[i].y + faces[i].height / 2) / sampleSize; } } void changeVibratoRate(Rectangle[] faces, int sampleSize, PImage img) { vibrato_rate = vibrato_rate / abs(vibrato_rate); int new_rate = 0; for (int i = 0; i < sampleSize; i++) { } }