...
Code Block | ||||
---|---|---|---|---|
| ||||
import org.openkinect.processing.*; Kinect2 kinect; int lowerThreshold = 0; int upperThreshold = 750; void setup() { size(512, 424); kinect = new Kinect2(this); kinect.initDepth(); kinect.initDevice(); } void draw() { PImage img = kinect.getDepthImage(); int[] depthMap = kinect.getRawDepth(); loadPixels(); for (int x = 0; x < kinect.depthWidth; x++) { for (int y = 0; y < kinect.depthHeight; y++) { int loc = x+ y * kinect.depthWidth; int rawDepth = depthMap[loc]; if (rawDepth > lowerThreshold && rawDepth < upperThreshold) { pixels[loc] = color(150, 50, 50); } else { pixels[loc] = img.pixels[loc]; } } } updatePixels(); } |
Code Block | ||||
---|---|---|---|---|
| ||||
import org.openkinect.processing.*; Kinect2 kinect; int[] depthMapRef; int[] depthMap; int Threshold = 500; int depthlength; void setup() { size(512, 424); depthlength = 512*424; kinect = new Kinect2(this); kinect.initDepth(); kinect.initDevice(); } void draw() { PImage img = kinect.getDepthImage(); depthMap = kinect.getRawDepth(); loadPixels(); if (depthMapRef == null) { depthMapRef = depthMap; } for (int x = 0; x < kinect.depthWidth; x++) { for (int y = 0; y < kinect.depthHeight; y++) { int loc = x+ y * kinect.depthWidth; int difference = abs(depthMap[loc]-depthMapRef[loc]); if ( difference > Threshold) { pixels[loc] = color(150, 50, 50); } else { pixels[loc] = img.pixels[loc]; } } } updatePixels(); } void mousePressed() { depthMapRef = depthMap; } |
...