Skip to content

Commit

Permalink
updated kinect_travel
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ckfg committed Nov 4, 2011
1 parent 103b656 commit e004728
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Kinect_travel/Kinect_travel.app/Contents/Info.plist
Expand Up @@ -3,7 +3,7 @@
<plist version="0.9">
<dict>
<key>CFBundleName</key>
<string>Kinect_travel</string>
<string>kinect_travel04</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleAllowMixedLocalizations</key>
Expand All @@ -21,7 +21,7 @@
<key>CFBundleIconFile</key>
<string>sketch.icns</string>
<key>CFBundleIdentifier</key>
<string>Kinect_travel</string>
<string>kinect_travel04</string>

<!-- http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html#//apple_ref/doc/uid/20001431-113616 -->
<key>LSUIPresentationMode</key>
Expand All @@ -41,7 +41,7 @@
<key>VMOptions</key>
<string> -Xms64m -Xmx1024m</string>
<key>MainClass</key>
<string>Kinect_travel</string>
<string>kinect_travel04</string>
<key>JVMVersion</key>
<string>1.5*</string>
<key>JVMArchs</key>
Expand All @@ -50,7 +50,7 @@
<string>ppc</string>
</array>
<key>ClassPath</key>
<string>$JAVAROOT/openkinect.jar:$JAVAROOT/Kinect_travel.jar:$JAVAROOT/core.jar:$JAVAROOT/openkinect.jar</string>
<string>$JAVAROOT/kinect_travel04.jar:$JAVAROOT/core.jar:$JAVAROOT/openkinect.jar</string>

<!-- http://developer.apple.com/releasenotes/Java/java141/system_properties/chapter_4_section_1.html#//apple_ref/doc/uid/TP30000285 -->
<key>Properties</key>
Expand Down
Binary file not shown.
Binary file not shown.
78 changes: 65 additions & 13 deletions Kinect_travel/Kinect_travel.pde
@@ -1,44 +1,74 @@
import org.openkinect.*;
import org.openkinect.processing.*;

int sW = 640;
int sH = 480;
int fps = 30;
int sWbutton = 240;
int sHbutton = 180;
int translateX = 200;
int translateY = 300;

Button bob, mary,louise;
PFont degFont;
int degFontSize = 50;
float deg = 0; // orig 15, goes -30 to 30
Kinect kinect;
boolean firstRun = true;

//--Kinect sectup
Kinect kinect;
boolean depth = true;
boolean rgbSwitch = false;
boolean ir = false;
boolean process = false;
int[] depthArray;
int pixelCounter = 1;
PImage displayImg;
int maxDepthValue = 1040; // full range 0-2047, rec'd 530-1040
int minDepthValue = 530;
//--

void setup() {
size(240,180);
size(sW,sH);
frameRate(fps);
smooth();
bob = new Button((width/2)-75,height/1.5,50,color(200,50,0),18,-30);
mary = new Button(width/2,height/1.5,50,color(0,50,200),18,0);
louise = new Button((width/2)+75,height/1.5,50,color(50,200,0),18,15);
kinect = new Kinect(this);
kinect.start();
displayImg = createImage(sW,sH,RGB);
bob = new Button((sWbutton/2)-75,sHbutton/1.5,50,color(200,50,0),18,-30);
mary = new Button(sWbutton/2,sHbutton/1.5,50,color(0,50,200),18,0);
louise = new Button((sWbutton/2)+75,sHbutton/1.5,50,color(50,200,0),18,15);
initKinect();
degFont = createFont("Arial",degFontSize);
}

void draw() {
background(135,135,155);
bob.update();
background(0);
depthArray = kinect.getRawDepth();
imageProcess();
image(displayImg,4,0);
fill(255);
textFont(degFont,int(degFontSize/4));
text(int(frameRate)+" fps",width-30,20);
translate(translateX,translateY);
fill(135,135,155,200);
rect(0,0,sWbutton,sHbutton);
bob.update();
mary.update();
louise.update();
if(!firstRun){
fill(0);
textFont(degFont,degFontSize);
text(int(deg),width/2,(height/2)-degFontSize);
text(int(deg),sWbutton/2,(sHbutton/2)-degFontSize);
kinect.tilt(deg);
//exit();
}else{
fill(0);
textFont(degFont,degFontSize);
text("?",width/2,(height/2)-degFontSize);
text("?",sWbutton/2,(sHbutton/2)-degFontSize);
}
}

void mouseReleased(){
bob.degKinect();
bob.degKinect();
mary.degKinect();
louise.degKinect();
}
Expand Down Expand Up @@ -81,7 +111,7 @@ class Button {
}

void checkButton() {
if(hitDetect(mouseX,mouseY,0,0,posX,posY,sizeXY,sizeXY)) {
if(hitDetect(mouseX,mouseY,0,0,posX+translateX,posY+translateY,sizeXY,sizeXY)) {
if(!mousePressed) {
hovered=true;
clicked=false;
Expand Down Expand Up @@ -147,8 +177,30 @@ if (keyCode==DOWN){
}
}

void imageProcess() {
for(int i=0;i<depthArray.length;i++) {
float q = map(depthArray[i],minDepthValue,maxDepthValue,255,0);
depthArray[i] = color(q);
}
displayImg.pixels = depthArray;
displayImg.updatePixels();
//displayImg.filter(GRAY);
//displayImg.filter(INVERT);
}

void initKinect() {
kinect = new Kinect(this);
kinect.start();
kinect.enableDepth(depth);
kinect.enableRGB(rgbSwitch);
kinect.enableIR(ir);
kinect.processDepthImage(process);
kinect.tilt(deg);
}

void stop() {
kinect.quit();
super.stop();
exit();
}

0 comments on commit e004728

Please sign in to comment.