public void track() { // Get the raw depth as array of integers depth = kinect.getRawDepth(); // Being overly cautious here if (depth == null) return; float sumX = 0; float sumY = 0; float count = 0; for (int x = 0; x < kw; x++) { for (int y = 0; y < kh; y++) { // Mirroring the image int offset = kw - x - 1 + y * kw; // Grabbing the raw depth int rawDepth = depth[offset]; // Testing against threshold if (rawDepth < threshold) { sumX += x; sumY += y; count++; } } } // As long as we found something if (count != 0) { loc = new PVector(sumX / count, sumY / count); } // Interpolating the location, doing it arbitrarily for now lerpedLoc.x = PApplet.lerp(lerpedLoc.x, loc.x, 0.3f); lerpedLoc.y = PApplet.lerp(lerpedLoc.y, loc.y, 0.3f); }