Kinect

edited January 2018 in Kinect

Hi, does anyone know how to change a color in this example. So I would like to have close points in red color and far in blue.

import org.openkinect.processing.*;

Kinect kinect;

void setup() {
  colorMode(HSB, 360, 180, 180);
  size(512, 424, P3D);
  kinect = new Kinect(this);
  kinect.initDepth();
}

void draw() {
  background(0);

  PImage img = kinect.getDepthImage();
  //image(img, 0, 0);

  int skip = 9;
  for (int x = 0; x < img.width; x+=skip) {
    for (int y = 0; y < img.height; y+=skip) {
      int index = x + y * img.width;
      float b = brightness(img.pixels[index]);
      float z = map(b, 0, 255, 60, -250);
      fill(0,100,80);
      pushMatrix();
      translate(x, y, z);
      ellipse(0, 0, skip/2, skip/2);
      popMatrix();
    }
  }
}
Tagged:

Answers

Sign In or Register to comment.