seanyseanyseany
YaBB Newbies
Offline
Posts: 6
My first program, works needs tidying
Jan 8th , 2009, 6:46pm
hi im very happy to have finished writing my first code as part of a uni project. It is a piece inspired by pop art. Creating a pop art style image from webcam which comes alive when detecting a face and pauses on the last face image when no face is there. As im quite new to processing i have put together bits of code from here and there and im not sure which bits should be taken out. Any tips would be great but im not asking anyone to re write it for me as im sure many of you could do this much better, however this needs to be my own work. (and im quite happy with it) oh and it requires having the face detect library installed if you wish to run it. http://tokage.cafe24.com/facedetect/index.htm download : http://tokage.cafe24.com/FaceDetectLibrary.zip thankyou import processing.video.*; import FaceDetect.*; FaceDetect fd; Capture cam; int MAX = 10; int[] x = new int[MAX]; int[] y = new int[MAX]; int[] r = new int[MAX]; int[][] Faces = new int[MAX][3]; void setup(){ size(960,720,P3D); cam = new Capture(this, 640, 480); fd = new FaceDetect(this); fd.start("haarcascade_frontalface_alt.xml", width,height,30); stroke(255,200,0); noFill(); } void draw(){ if (cam.available()) { cam.read(); Faces = fd.face(cam); int count = Faces.length; // println(count); if (count>0){ int cols = 4; int rows = 4; int w = width/cols; int h = height/rows; for (int i =0; i<height; i+=h){ for (int j=0; j<width; j+=w){ tint(map(i, 0, height, 10, 255), map(j, 0, width, 10, 255), 128); image(cam, j, i, w, h); } } filter (POSTERIZE, 6); } } }