Animating shape with processing + Kinect
in
Contributed Library Questions
•
2 years ago
Hi im new to processing and im trying to experiment with the kinect using Daniel's openKinect library
Right now I created a shape that uses the average point tracking to change color. Right now it's a bit buggy and doesn't seem to be consistent so I'm not sure what i need to adjust to make it work better.
I also want the shape to animate using the tracking as well. Specifically i would want the shape to be morphed deformed by hand movements.
here's the code:
import fullscreen.*;
FullScreen fs;
import org.openkinect.*;
import org.openkinect.processing.*;
KinectTracker tracker;
Kinect kinect;
void setup() {
size(600, 800);
background(255);
kinect = new Kinect(this);
tracker = new KinectTracker();
noStroke();
fs = new FullScreen(this);
fs.enter();
}
void draw() {
tracker.track();
PVector v1 = tracker.getPos();
fill(v2.x+200);
beginShape();
vertex(455.5, 55);
bezierVertex(306.5, 7.5, 174, 243, 168, 338);
bezierVertex(161, 435, 79, 580, 63, 668);
bezierVertex(11, 935, 525, 499, 484, 408);
bezierVertex(468, 361, 371, 311, 431, 272);
bezierVertex(491, 233, 528, 272, 541, 211);
bezierVertex(554, 151, 507, 73, 455.5, 55);
endShape();
fill(v2.x+150);
beginShape();
vertex(445, 70);
bezierVertex(307, 26, 183, 242, 175, 332);
bezierVertex(170, 422, 95, 558, 79, 639);
bezierVertex(31, 890, 509, 482, 471, 397);
bezierVertex(456, 354, 366, 309, 422, 271);
bezierVertex(478, 235, 512, 271, 524, 214);
bezierVertex(537, 158, 492, 86, 445, 70);
endShape();
fill(v2.x+125);
beginShape();
vertex(434, 80);
bezierVertex(306, 43, 191, 242, 185, 336);
bezierVertex(180, 410, 110, 535, 95, 610);
bezierVertex(51, 841, 495, 465, 457, 384);
bezierVertex(445, 347, 361, 304, 413, 269);
bezierVertex(465, 235, 496, 268, 508, 216);
bezierVertex(519, 165, 477, 98, 434, 80);
endShape();
fill(v2.x+100);
beginShape();
vertex(426, 94);
bezierVertex(308, 56, 202, 240, 196, 318);
bezierVertex(192, 394, 127, 510, 114, 579);
bezierVertex(74, 792, 481, 444, 448, 372);
bezierVertex(436, 337, 359, 297, 406, 266);
bezierVertex(454, 235, 483, 266, 493, 217);
bezierVertex(504, 169, 466, 107, 426, 94);
endShape();
fill(v2.x+75);
beginShape();
vertex(418, 107);
bezierVertex(310, 72, 216, 241, 209, 311);
bezierVertex(204, 382, 145, 486, 132, 549);
bezierVertex(97, 743, 467, 427, 437, 360);
bezierVertex(427, 329, 357, 292, 401, 263);
bezierVertex(444, 235, 470, 262, 480, 218);
bezierVertex(490, 175, 454, 118, 418, 107);
endShape();
fill(v2.x+50);
beginShape();
vertex(412, 118);
bezierVertex(315, 86, 228, 238, 223, 302);
bezierVertex(219, 365, 166, 461, 154, 518);
bezierVertex(121, 692, 457, 406, 430, 342);
bezierVertex(420, 317, 357, 285, 396, 259);
bezierVertex(436, 232, 459, 258, 468, 219);
bezierVertex(477, 179, 445, 129, 412, 118);
endShape();
fill(v2.x+25);
beginShape();
vertex(406, 137);
bezierVertex(319, 108, 242, 244, 237, 301);
bezierVertex(234, 359, 186, 443, 177, 494);
bezierVertex(147, 651, 447, 396, 422, 343);
bezierVertex(413, 314, 357, 287, 392, 263);
bezierVertex(426, 240, 449, 263, 455, 228);
bezierVertex(464, 193, 436, 147, 406, 137);
endShape();
fill(v2.x);
beginShape();
vertex(400, 149);
bezierVertex(322, 124, 252, 244, 249, 294);
bezierVertex(246, 345, 204, 419, 196, 464);
bezierVertex(169, 602, 433, 377, 413, 328);
bezierVertex(404, 306, 355, 280, 385, 260);
bezierVertex(417, 240, 436, 259, 441, 228);
bezierVertex(449, 198, 424, 158, 400, 149);
endShape();
}
void keyPressed() {
int t = tracker.getThreshold();
if (key == CODED) {
if (keyCode == UP) {
t+=5;
tracker.setThreshold(t);
}
else if (keyCode == DOWN) {
t-=5;
tracker.setThreshold(t);
}
}
}
void stop() {
tracker.quit();
super.stop();
}
any help would be much appreciated thanks.
Right now I created a shape that uses the average point tracking to change color. Right now it's a bit buggy and doesn't seem to be consistent so I'm not sure what i need to adjust to make it work better.
I also want the shape to animate using the tracking as well. Specifically i would want the shape to be morphed deformed by hand movements.
here's the code:
import fullscreen.*;
FullScreen fs;
import org.openkinect.*;
import org.openkinect.processing.*;
KinectTracker tracker;
Kinect kinect;
void setup() {
size(600, 800);
background(255);
kinect = new Kinect(this);
tracker = new KinectTracker();
noStroke();
fs = new FullScreen(this);
fs.enter();
}
void draw() {
tracker.track();
PVector v1 = tracker.getPos();
fill(v2.x+200);
beginShape();
vertex(455.5, 55);
bezierVertex(306.5, 7.5, 174, 243, 168, 338);
bezierVertex(161, 435, 79, 580, 63, 668);
bezierVertex(11, 935, 525, 499, 484, 408);
bezierVertex(468, 361, 371, 311, 431, 272);
bezierVertex(491, 233, 528, 272, 541, 211);
bezierVertex(554, 151, 507, 73, 455.5, 55);
endShape();
fill(v2.x+150);
beginShape();
vertex(445, 70);
bezierVertex(307, 26, 183, 242, 175, 332);
bezierVertex(170, 422, 95, 558, 79, 639);
bezierVertex(31, 890, 509, 482, 471, 397);
bezierVertex(456, 354, 366, 309, 422, 271);
bezierVertex(478, 235, 512, 271, 524, 214);
bezierVertex(537, 158, 492, 86, 445, 70);
endShape();
fill(v2.x+125);
beginShape();
vertex(434, 80);
bezierVertex(306, 43, 191, 242, 185, 336);
bezierVertex(180, 410, 110, 535, 95, 610);
bezierVertex(51, 841, 495, 465, 457, 384);
bezierVertex(445, 347, 361, 304, 413, 269);
bezierVertex(465, 235, 496, 268, 508, 216);
bezierVertex(519, 165, 477, 98, 434, 80);
endShape();
fill(v2.x+100);
beginShape();
vertex(426, 94);
bezierVertex(308, 56, 202, 240, 196, 318);
bezierVertex(192, 394, 127, 510, 114, 579);
bezierVertex(74, 792, 481, 444, 448, 372);
bezierVertex(436, 337, 359, 297, 406, 266);
bezierVertex(454, 235, 483, 266, 493, 217);
bezierVertex(504, 169, 466, 107, 426, 94);
endShape();
fill(v2.x+75);
beginShape();
vertex(418, 107);
bezierVertex(310, 72, 216, 241, 209, 311);
bezierVertex(204, 382, 145, 486, 132, 549);
bezierVertex(97, 743, 467, 427, 437, 360);
bezierVertex(427, 329, 357, 292, 401, 263);
bezierVertex(444, 235, 470, 262, 480, 218);
bezierVertex(490, 175, 454, 118, 418, 107);
endShape();
fill(v2.x+50);
beginShape();
vertex(412, 118);
bezierVertex(315, 86, 228, 238, 223, 302);
bezierVertex(219, 365, 166, 461, 154, 518);
bezierVertex(121, 692, 457, 406, 430, 342);
bezierVertex(420, 317, 357, 285, 396, 259);
bezierVertex(436, 232, 459, 258, 468, 219);
bezierVertex(477, 179, 445, 129, 412, 118);
endShape();
fill(v2.x+25);
beginShape();
vertex(406, 137);
bezierVertex(319, 108, 242, 244, 237, 301);
bezierVertex(234, 359, 186, 443, 177, 494);
bezierVertex(147, 651, 447, 396, 422, 343);
bezierVertex(413, 314, 357, 287, 392, 263);
bezierVertex(426, 240, 449, 263, 455, 228);
bezierVertex(464, 193, 436, 147, 406, 137);
endShape();
fill(v2.x);
beginShape();
vertex(400, 149);
bezierVertex(322, 124, 252, 244, 249, 294);
bezierVertex(246, 345, 204, 419, 196, 464);
bezierVertex(169, 602, 433, 377, 413, 328);
bezierVertex(404, 306, 355, 280, 385, 260);
bezierVertex(417, 240, 436, 259, 441, 228);
bezierVertex(449, 198, 424, 158, 400, 149);
endShape();
}
void keyPressed() {
int t = tracker.getThreshold();
if (key == CODED) {
if (keyCode == UP) {
t+=5;
tracker.setThreshold(t);
}
else if (keyCode == DOWN) {
t-=5;
tracker.setThreshold(t);
}
}
}
void stop() {
tracker.quit();
super.stop();
}
any help would be much appreciated thanks.
1