/* * ENJOY SURVEILLANCE * EVERYBODY LOVES A CLOWN * * Michael Schieben, 2008 * babe@rockitbaby.de * http://www.rockitbaby.de * * libs used * - http://www.superduper.org/processing/fullscreen_api/ * - http://ubaa.net/shared/processing/opencv/ * * feel free to play around an make something meaningful * * released under * Attribution-Noncommercial-Share Alike 3.0 * http://creativecommons.org/licenses/by-nc-sa/3.0/de/ */ import hypermedia.video.*; import fullscreen.*; FullScreen fs; OpenCV opencv; Rectangle[] faces; void setup() { size(640, 480); opencv = new OpenCV(this); opencv.capture(640, 480); opencv.cascade(OpenCV.CASCADE_FRONTALFACE_ALT); faces = opencv.detect(1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40); fs = new FullScreen(this); fs.enter(); noCursor(); background(0); } void draw() { background(0); cam(); noses(); chrome(); interlaceFilter(); noiseFilter(); rec(); noCursor(); } void rec() { if (mousePressed && frameCount % 2 == 0) { save("rec/" + str(year()) + str(month()) + str(day()) + "-" + str(hour()) + str(minute()) + str(second()) + "-" + str(frameCount) + ".png"); fill(255, 0, 0); ellipse(width - 40, 20, 15, 15); } } void cam() { opencv.read(); opencv.flip(OpenCV.FLIP_HORIZONTAL); opencv.convert(GRAY); opencv.brightness(45); opencv.contrast(35); image(opencv.image(), 0, 0); } void noses() { faces = opencv.detect(1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40); for(int i=0; i < faces.length && i < 5; i++) { noStroke(); float centerX = faces[i].x + faces[i].width / 2; float centerY = faces[i].y + faces[i].height / 2; fill(255, 0, 0); float h = faces[i].height / 6; ellipse(centerX, centerY + h / 2, h * 1.4, h * 1.4); } } void noiseFilter() { int dimension = (width*height); loadPixels(); for (int i = 0; i < dimension; i += random(1,5)) { pixels[i] = color(red(pixels[i]), green(pixels[i]), min(255, blue(pixels[i]) + random(0, 50))); } updatePixels(); } void interlaceFilter() { noStroke(); for (int i = 0; i < height; i += 6) { fill(100, 100, 255, random(10, 30)); rect(0, i, width, 2); } } void chrome() { noStroke(); fill(0, 0, 0, 220); rect(0, 0, width - 10, 10); rect(0, 10, 10, height); rect(10, height - 10, width - 10, 10); rect(width - 10, 0, 10, height); }