Browse Source

init repo

develop
Carmine De Rosa 5 years ago
parent
commit
88f16d8c8a
  1. 188
      Texture/Texture.pde
  2. BIN
      Texture/data/drone1.wav
  3. BIN
      Texture/data/drone2.wav
  4. BIN
      Texture/data/drone3.wav
  5. BIN
      Texture/data/drone4.wav
  6. BIN
      Texture/data/drone5.flac
  7. BIN
      Texture/data/drone5.wav
  8. BIN
      Texture/data/drone6.wav
  9. BIN
      Texture/data/touch.png

188
Texture/Texture.pde

@ -0,0 +1,188 @@
import org.openkinect.freenect.*;
import org.openkinect.processing.*;
import processing.sound.*;
SoundFile drone1;
SoundFile drone2;
SoundFile drone3;
SoundFile drone4;
Kinect kinect;
PImage touchImg;
int tintCount = 0;
int tintDir = 0;
int minDepth = 795;
int maxDepth = 805;
float deg;
boolean ir = false;
boolean colorDepth = true;
boolean mirror = false;
float freqs[] = {0, 0, 0, 0};
void setup() {
//size(1024, 768, P3D);
//size(800, 600, P3D);
fullScreen(2);
touchImg = loadImage("touch.png");
kinect = new Kinect(this);
kinect.initDepth();
kinect.initVideo();
//kinect.enableIR(ir);
kinect.enableColorDepth(colorDepth);
kinect.enableMirror(mirror);
deg = kinect.getTilt();
drone1 = new SoundFile(this, "drone1.wav");
drone2 = new SoundFile(this, "drone2.wav");
drone3 = new SoundFile(this, "drone3.wav");
drone4 = new SoundFile(this, "drone5.wav");
drone1.amp(0.1);
drone2.amp(0.1);
drone3.amp(0.1);
drone4.amp(0.1);
drone1.loop();
drone2.loop();
drone3.loop();
drone4.loop();
colorMode(HSB, 255, 100, 100);
background(255);
noStroke();
smooth();
//frameRate(15);
}
void draw() {
background(255);
//image(kinect.getVideoImage(), 0, 0);
//image(kinect.getDepthImage(), 640, 0);
PImage img = kinect.getDepthImage();
int[] rawDepth = kinect.getRawDepth();
color c = color(255);
int skip = 10;
int freqsCnt[] = {0, 0, 0, 0};
//fill(c, 20);
//rect(0, 0, width, height);
//image(img, 0, 0);
for(int x = 0; x < img.width; x += skip){
for(int y = 0; y < img.height; y += skip){
int index = x + y * img.width;
float cDepth = 30-map(rawDepth[index], minDepth, maxDepth, 0, 30);
float cColor = map(rawDepth[index], minDepth, maxDepth, 0, 255);
c = color(cColor, 100, 100);
if (rawDepth[index] >= minDepth && rawDepth[index] <= maxDepth) {
fill(c, 150);
ellipse(x*1.55, y*1.40, cDepth*2, cDepth*2);
if(cColor <= 64){
freqsCnt[0]++;
}
if(cColor > 64 && cColor <= 128){
freqsCnt[1]++;
}
if(cColor > 128 && cColor <= 196){
freqsCnt[2]++;
}
if(cColor > 196){
freqsCnt[3]++;
}
}
}
}
drone1.amp(map(freqsCnt[0],0,300,0.01,.9));
drone2.amp(map(freqsCnt[1],0,300,0.01,1));
drone3.amp(map(freqsCnt[2],0,300,0.01,.6));
drone4.amp(map(freqsCnt[3],0,300,0.01,.7) );
if(freqsCnt[0] == 0 && freqsCnt[1] == 0 && freqsCnt[2] == 0 && freqsCnt[3] == 0) {
tint(255, tintCount);
image(touchImg, (width/2)-touchImg.width/2, (height/2)-touchImg.height/2);
if(tintDir==0) {
tintCount++;
} else {
tintCount--;
}
if(tintCount >= 255) {tintDir = 1;}
if(tintCount <= 0) {tintDir = 0;}
println(freqsCnt[0] + " - " + freqsCnt[1] + " - " + freqsCnt[2] + " - " + freqsCnt[3] + " - " + tintCount + " - " + tintDir);
} else {
if(tintCount > 0) {
tintCount--;
tint(255, tintCount);
image(touchImg, (width/2)-touchImg.width/2, (height/2)-touchImg.height/2);
}
}
/*
fill(0);
text("TILT: " + deg, 10, 20);
text("THRESHOLD: [" + minDepth + ", " + maxDepth + "]", 10, 36);
text("FREQS: [" + freqsCnt[0] + ", " + freqsCnt[1] + ", " + freqsCnt[2] + ", " + freqsCnt[3] + "]", 10, 52);
*/
/*
fill(255);
text(
"Press 'i' to enable/disable between video image and IR image, " +
"Press 'c' to enable/disable between color depth and gray scale depth, " +
"Press 'm' to enable/diable mirror mode, "+
"UP and DOWN to tilt camera " +
"Framerate: " + int(frameRate), 10, 515);
*/
}
void keyPressed() {
if (key == 'i') {
ir = !ir;
kinect.enableIR(ir);
} else if (key == 'c') {
colorDepth = !colorDepth;
kinect.enableColorDepth(colorDepth);
} else if(key == 'm'){
mirror = !mirror;
kinect.enableMirror(mirror);
} else if (key == 'a') {
minDepth = constrain(minDepth+10, 0, maxDepth);
println("minDepth: "+minDepth);
} else if (key == 's') {
minDepth = constrain(minDepth-10, 0, maxDepth);
println("minDepth: "+minDepth);
} else if (key == 'z') {
maxDepth = constrain(maxDepth+10, minDepth, 2047);
println("maxDepth: "+maxDepth);
} else if (key =='x') {
maxDepth = constrain(maxDepth-10, minDepth, 2047);
println("maxDepth: "+maxDepth);
}
if (key == CODED) {
if (keyCode == UP) {
deg++;
} else if (keyCode == DOWN) {
deg--;
}
}
deg = constrain(deg, 0, 30);
kinect.setTilt(deg);
}

BIN
Texture/data/drone1.wav

Binary file not shown.

BIN
Texture/data/drone2.wav

Binary file not shown.

BIN
Texture/data/drone3.wav

Binary file not shown.

BIN
Texture/data/drone4.wav

Binary file not shown.

BIN
Texture/data/drone5.flac

Binary file not shown.

BIN
Texture/data/drone5.wav

Binary file not shown.

BIN
Texture/data/drone6.wav

Binary file not shown.

BIN
Texture/data/touch.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Loading…
Cancel
Save