Hi, im a newbie in Processing and need some help or advice.
i just found free to share code by one guys(is just painting with stroke and random colors) and i add fews feature with minim lib. Basically u can paint with kinect and change colors and stroke depends volumes.
My first question can i use gesture/volumes to save instead using keyboard? example: would like to save with left hand up :), or using volume when i reach high levels.
Second, i know kinect 360 just can handle with 480x640, im want bigger canvas like fullscreen. Can i Rescale it without effect on my lines ? i tried fullscreen but the area where i can paint is just same.
import SimpleOpenNI.*;
import fullscreen.*;
import ddf.minim.analysis.*;
import ddf.minim.*;
SimpleOpenNI kinect;
int closestValue;
int closestX;
int closestY;
float lastX;
float lastY;
int previousX;
int previousY;
Minim minim;
AudioInput input;
FFT fft;
void setup()
{
size(640, 480);
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
minim = new Minim(this);
input = minim.getLineIn();
fft = new FFT(input.bufferSize(),input.sampleRate());
background(255);
}
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];
//nejnizsi hodnota vs vzdalenost
//620 nebo 2m minimum
//1525 nebo 5m maximum
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);
fft.forward(input.mix);
float max = 0.0;
for(int i = 0; i < fft.specSize();i++)
{
float loudness = fft.getBand(i);
if (loudness > max) {
max = loudness;
}
}
stroke(max%254.0,max%150.0+5,max%200.0+3);
strokeWeight((max%100.0)+1);
//hlasitost od 4 do 30/ max, pro nekonecna hodnota.
line(lastX, lastY, interpolatedX, interpolatedY);
lastX = interpolatedX;
lastY = interpolatedY;
}
void mousePressed(){
save("pollock.png");
background(255);
}
Thanks for helps and advice, and sorry for my bad english