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); }
public void draw() { img.loadPixels(); colorMode(HSB, 1, 1, 1); // for(int i = 0; i < settings.passesperupdate; i++ ){ initBuckets(); runBuckets(); // } totalphotonscast = 0; // settings.exposure = (float) mouseX / 100; colorMode(RGB, 1); for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { double div = count[x + y * h] / settings.exposure; totalphotonscast += count[x + y * h]; int i = (x + y * w) * 3; int c = 0; if (mousePressed && mouseButton == LEFT) { // show grayscale, so early color renders dont look like shit c = color((float) ((plate[i + 0] + plate[i + 1] + plate[i + 2]) / div / 3)); } else { // show color c = color( (float) (plate[i + 0] / div), (float) (plate[i + 1] / div), (float) (plate[i + 2] / div)); } img.pixels[x + y * w] = c; } } img.updatePixels(); image(img, 0, 0, (float) (w * settings.scale), (float) (h * settings.scale)); println( "Ms: " + (millis() - millis) + " - Pass: "******" - " + totalphotonscast + " rays cast so far - " + (totalphotonscast - lastphotonscast) / (millis() - millis) * 1000 + " rays per second."); millis = millis(); lastphotonscast = totalphotonscast; // if( frameCount % 1 == 0 ){ if (keyPressed) { savedframecount += 1; saveFrame("out2/" + savedframecount + "_box.tiff"); println("Saved a frame."); // wipePlate(); } if (mousePressed && mouseButton == RIGHT) { FilmGraph.DrawGraph(this); } }