-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathsimpleGreenOpenKinect
66 lines (51 loc) · 1.42 KB
/
simpleGreenOpenKinect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Daniel Shiffman
// All features test
// https://github.com/shiffman/OpenKinect-for-Processing
// http://shiffman.net/p5/kinect/
import org.openkinect.freenect.*;
import org.openkinect.processing.*;
Kinect kinect;
PImage depthImg;
float deg;
boolean ir = false;
boolean colorDepth = false;
boolean mirror = false;
int minDepth = 60;
int maxDepth = 860;
int cxoffset = 0;
int cyOffset = 10;
void setup() {
size(1280, 520);
kinect = new Kinect(this);
kinect.initDepth();
kinect.initVideo();
//kinect.enableIR(ir);
kinect.enableColorDepth(colorDepth);
deg = kinect.getTilt();
// kinect.tilt(deg);
depthImg = new PImage(kinect.width, kinect.height);
}
void draw() {
background(0);
image(kinect.getVideoImage(), 0, 0);
//image(kinect.getDepthImage(), 0, 0);
// Threshold the depth image
int[] rawDepth = kinect.getRawDepth();
for (int row=0; row < kinect.height-cyOffset; row++) {
for (int col=0; col < kinect.width; col++) {
int offset = row * kinect.width + col;
int coffset = (row+cyOffset) * kinect.width + col;
if (rawDepth[offset] >= minDepth && rawDepth[offset] <= maxDepth) {
depthImg.pixels[offset] = kinect.getVideoImage().pixels[coffset];
} else {
depthImg.pixels[offset] = color(0);
}
}
}
// Draw the thresholded image
depthImg.updatePixels();
image(depthImg, kinect.width, 0);
}
void keyPressed(){
if (key == '+') cyOffset ++;
}