import gab.opencv.*; import processing.video.*; import java.awt.Rectangle; OpenCV opencv; Rectangle[] faces; Capture cam; //Variables representing the location of center of face int faceX = 0, faceY = 0; PImage image; void setup() { background(0); size(640, 480); //initalize webcam String[] cameras = Capture.list(); if (cameras.length == 0) { println("There are no cameras available for capture."); exit(); } else { println("Available cameras:"); for (int i = 0; i < cameras.length; i++) { println(cameras[i]); } cam = new Capture(this, cameras[0]); cam.start(); } } void draw() { cam.read(); getFace(); //Changes faceX & faceY to the coordinates of the center of the face after each loop of the draw() method for (int i = 0; i < faces.length; i++) { faceX = faces[i].x + (faces[i].width / 2); faceY = faces[i].y + (faces[i].height / 2); } } void getFace() { opencv = new OpenCV(this, cam); opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE); faces = opencv.detect(); }