Skip to content

Commit dc7a8c8

Browse files
committed
Merge pull request shiffman#71 from nicolasraga1/master
Added documentation and examples
2 parents 5046fdd + 8d882e3 commit dc7a8c8

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

OpenKinect-Processing/examples/Kinect_v1/DepthThreshold/DepthThreshold.pde

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ Kinect kinect;
1616
PImage depthImg;
1717

1818
// Which pixels do we care about?
19-
int minDepth = 60;
20-
int maxDepth = 860;
19+
// These thresholds can also be found with a variaty of methods
20+
float minDepth = 996;
21+
float maxDepth = 2493;
2122

2223
// What is the kinect's angle
2324
float angle;
@@ -37,6 +38,10 @@ void draw() {
3738
// Draw the raw image
3839
image(kinect.getDepthImage(), 0, 0);
3940

41+
// Calibration
42+
//minDepth = map(mouseX,0,width, 0, 4500);
43+
//maxDepth = map(mouseY,0,height, 0, 4500);
44+
4045
// Threshold the depth image
4146
int[] rawDepth = kinect.getRawDepth();
4247
for (int i=0; i < rawDepth.length; i++) {
@@ -50,10 +55,16 @@ void draw() {
5055
// Draw the thresholded image
5156
depthImg.updatePixels();
5257
image(depthImg, kinect.width, 0);
53-
58+
59+
//Comment for Calibration
5460
fill(0);
5561
text("TILT: " + angle, 10, 20);
5662
text("THRESHOLD: [" + minDepth + ", " + maxDepth + "]", 10, 36);
63+
64+
//Calibration Text
65+
//fill(255);
66+
//textSize(32);
67+
//text(minDepth + " " + maxDepth, 10, 64);
5768
}
5869

5970
// Adjust the angle and the depth threshold min and max

OpenKinect-Processing/examples/Kinect_v1/PointCloud/PointCloud.pde

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ void draw() {
4040

4141
// Translate and rotate
4242
translate(width/2, height/2, -50);
43-
rotateY(a);
44-
43+
//rotateY(a);
44+
45+
// Nested for loop that initializes x and y pixels and, for those less than the
46+
// maximum threshold and at every skiping point, the offset is caculated to map
47+
// them on a plane instead of just a line
4548
for (int x = 0; x < kinect.width; x += skip) {
4649
for (int y = 0; y < kinect.height; y += skip) {
4750
int offset = x + y*kinect.width;
@@ -73,13 +76,15 @@ float rawDepthToMeters(int depthValue) {
7376
return 0.0f;
7477
}
7578

79+
// Only needed to make sense of the ouput depth values from the kinect
7680
PVector depthToWorld(int x, int y, int depthValue) {
7781

7882
final double fx_d = 1.0 / 5.9421434211923247e+02;
7983
final double fy_d = 1.0 / 5.9104053696870778e+02;
8084
final double cx_d = 3.3930780975300314e+02;
8185
final double cy_d = 2.4273913761751615e+02;
8286

87+
// Drawing the result vector to give each point its three-dimensional space
8388
PVector result = new PVector();
8489
double depth = depthLookUp[depthValue];//rawDepthToMeters(depthValue);
8590
result.x = (float)((x - cx_d) * depth * fx_d);

OpenKinect-Processing/examples/Kinect_v1/PointCloudOGL/PointCloudOGL.pde

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ void draw() {
4747

4848
image(kinect.getDepthImage(), 0, 0, 320, 240);
4949

50+
// Set up origin at middle of display, scale, and translate
5051
pushMatrix();
5152
translate(width/2, height/2, 50);
5253
scale(150);
@@ -97,5 +98,6 @@ void draw() {
9798
text(frameRate, 50, 50);
9899

99100
// Rotate
101+
// Uncomment for rotation
100102
// a += 0.015f;
101103
}

0 commit comments

Comments
 (0)