public void display() { PImage img = kinect.getDepthImage(); // PImage img = kinect.getVideoImage(); // Being overly cautious here if (depth == null || img == null) return; // Going to rewrite the depth image to show which pixels are in threshold // A lot of this is redundant, but this is just for demonstration purposes display.loadPixels(); for (int x = 0; x < kw; x++) { for (int y = 0; y < kh; y++) { // mirroring image int offset = kw - x - 1 + y * kw; // Raw depth int rawDepth = depth[offset]; int pix = x + y * display.width; if (rawDepth < threshold) { // A red color instead display.pixels[pix] = p.color(150, 50, 50); } else { display.pixels[pix] = img.pixels[offset]; } } } display.updatePixels(); // Draw the image p.image(display, 0, 0); }