-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptischopzetkinect.pde
105 lines (86 loc) · 2.14 KB
/
optischopzetkinect.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import org.openkinect.freenect.*;
import org.openkinect.processing.*;
Kinect kinect;
float minThresh = 200;
float maxThresh = 600;
PImage img;
float angle;
color[] colArray = {
color(128, 128, 255),
color(0, 255, 255),
color(248, 64, 248),
color(64, 255, 255)
};
void setup() {
size(800, 800);
surface.setLocation(957, 0);
noStroke();
fill(0, 15, 30);
kinect = new Kinect(this);
kinect.enableMirror(true);
kinect.initDepth();
img = createImage(kinect.width, kinect.height, RGB);
}
void draw() {
background(20);
int[] depth = kinect.getRawDepth();
float sumX = 0;
float sumY = 0;
float totalPixels = 0;
for (int x = 0; x < kinect.width; x++) {
for (int y = 0; y < kinect.height; y++) {
int offset = x + y*kinect.width;
int d = depth[offset];
if (d > minThresh && d < maxThresh) {
img.pixels[offset] = color(255, 200, 100);
sumX += x;
sumY += y;
totalPixels++;
} else {
img.pixels[offset] = color(0);
}
}
}
float avgX = sumX / totalPixels;
float avgY = sumY / totalPixels;
fill(150, 0, 255);
ellipse(avgX, avgY, 5, 5);
img.updatePixels();
imageMode (CENTER);
//mouseX = constrain(mouseX, 10, width);
//mouseY = constrain(mouseY, 10, width);
avgX = constrain(avgX, 5, width);
avgY = constrain(avgY, 5, width);
float x = width;
float dia = 300;
//int num = 100;
float num = avgX;
float mun = avgY;
translate(width/2, height/2);
for (float a=0; a<360; a+=90) {
//fill(248, 64, 248);
fill(64, 255, 255);
//stroke(20);
//strokeWeight(20);
//fill(colArray[int(random(5))]);
rotate(radians(a));
pushMatrix();
for (int i=0; i<num; i++) {
scale(0.95);
rotate(radians(angle));
ellipse(x, 0, dia, dia);
}
popMatrix();
pushMatrix();
for (int i=0; i<mun; i++) {
fill(64, 255, 255);
//stroke(20);
//strokeWeight(20);
scale(0.95);
rotate(-radians(angle));
ellipse(x, 0, dia, dia);
}
popMatrix();
}
angle+=0.01;
}