-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathACM_Drawer.pde
69 lines (44 loc) · 1.11 KB
/
ACM_Drawer.pde
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
67
68
69
import SimpleOpenNI.*;
SimpleOpenNI kinect;
int closestValue;
int closestX;
int closestY;
float lastX;
float lastY;
void setup(){
size(640, 480);
kinect= new SimpleOpenNI(this);
kinect.enableDepth();
// kinect.enableRGB();
}
void draw(){
closestValue = 8000;
kinect.update();
int[] depthValues = kinect.depthMap();
for( int y=0; y<480; y++){
for(int x=0; x<640; x++){
int reversedX = 640-x-1;
int i = reversedX+y *640;
int currentDepthValue = depthValues[i];
if(currentDepthValue >610 && currentDepthValue < 1525 && currentDepthValue < closestValue){
closestValue= currentDepthValue;
closestX = x;
closestY = y;
}
}
}
float interpolatedX = lerp(lastX, closestX, 0.3f);
float interpolatedY = lerp(lastY, closestY, 0.3f);
//PImage depthImage= kinect.depthImage();
//PImage rgbImage= kinect.rgbImage();
//image(depthImage, 0,0);
//image(rgbImage, 640,0);
stroke(255,0,0);
strokeWeight(3);
line(lastX, lastY, interpolatedX, interpolatedY);
lastX = interpolatedX;
lastY = interpolatedY;
}
void mousePressed(){
background(0);
}