Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wird eine Kinect Kamera v1 verwendet, muss die Referenz und Initialisierung entsprechend angepasst werden:

Code Block
Kinect kinect; // ohne "2"
void setup() {
  kinect = new Kinect2Kinect(this);
  kinect.initDevice();
}

...

Code Block
void videoEvent(Kinect k) {
  // There has been a video event!
}
Code Block
titleBeispiel
collapsetrue
import org.openkinect.processing.*;

Kinect2 kinect;

void setup() {
  size(1920, 1080);

  kinect = new Kinect2(this);
  kinect.initVideo();
  kinect.initDevice();
}

void draw() {
  image(kinect.getVideoImage(), 0, 0);
}

Infrarot Bild

Zuerst muss der Infrarot-Stream der Kamera in der setup() Funktion aktiviert werden:

...

Code Block
titleBeispiel
collapsetrue
import org.openkinect.processing.*;

Kinect2 kinect;

void setup() {
  size(640512, 360424);

  kinect = new Kinect2(this);
  kinect.initIR();
  kinect.initDevice();
}

void draw() {
  image(kinect.getIrImage(), 0, 0);
}

...

Code Block
titleBeispiel
collapsetrue
import org.openkinect.processing.*;

Kinect2 kinect;

void setup() {
  size(512, 424);

  kinect = new Kinect2(this);
  kinect.initDepth();

    kinect.initDevice();
}

void draw() {
  image(kinect.getDepthImage(), 0, 0);
}

...

Code Block
titleBeispiel
collapsetrue
import org.openkinect.processing.*;
import peasy.*;

Kinect2 kinect;
PeasyCam cam;

void setup() {
  size(5121920, 4241080, P3D);
  cam = new PeasyCam(this, 1000);
  cam.setMaximumDistance(5000);
  
  kinect = new Kinect2(this);
  kinect.initDepth();
  kinect.initDevice();
}

void draw() {
  background(0);
  
  int[] depthMap = kinect.getRawDepth();
  int stepSize = 2;
  
  for(int x=0; x<kinect.depthWidth; x+=stepSize) {
    for(int y=0; y<kinect.depthHeight; y+=stepSize) {
      int loc = x+y*kinect.depthWidth;
      
      PVector point = depthToPointCloudPos(x, y, depthMap[loc]);
      
      stroke(255);
      point(point.x, point.y, point.z);
    }
  }
}

PVector depthToPointCloudPos(int x, int y, float depthValue) {
  PVector point = new PVector();
  point.z = (depthValue);
  point.x = (x - CameraParams.cx) * point.z / CameraParams.fx;
  point.y = (y - CameraParams.cy) * point.z / CameraParams.fy;
  return point;
}

static class CameraParams {
  static float cx = 254.878f;
  static float cy = 205.395f;
  static float fx = 365.456f;
  static float fy = 365.456f;
  static float k1 = 0.0905474;
  static float k2 = -0.26819;
  static float k3 = 0.0950862;
  static float p1 = 0.0;
  static float p2 = 0.0;
}

...

Code Block
titleBeispiel
collapsetrue
import org.openkinect.processing.*;

Kinect2 kinect;

void setup() {
  size(512, 424);

  kinect = new Kinect2(this);
  kinect.initRegistered();
  
  kinect.initDevice();
}

void draw() {
  image(kinect.getRegisteredImage(), 0, 0);
}

...