Skip to content

Instantly share code, notes, and snippets.

@jaycody
Created March 31, 2017 22:42
Show Gist options
  • Save jaycody/a43cc16376caeb79c1f24e1a055b198c to your computer and use it in GitHub Desktop.
Save jaycody/a43cc16376caeb79c1f24e1a055b198c to your computer and use it in GitHub Desktop.
keyPressed and ready to go
// Handle keypress to adjust parameters
void keyPressed() {
println("*** FRAMERATE: " + frameRate);
// up arrow to move kinect down
if (keyCode == UP) {
kinecter.kAngle++;
kinecter.kAngle = constrain(kinecter.kAngle, 0, 30);
kinecter.kinect.tilt(kinecter.kAngle);
}
// down arrow to move kinect down
else if (keyCode == DOWN) {
kinecter.kAngle--;
kinecter.kAngle = constrain(kinecter.kAngle, 0, 30);
kinecter.kinect.tilt(kinecter.kAngle);
}
// space bar for settings to adjust kinect depth
else if (keyCode == 32) {
showSettings = !showSettings;
}
// 'a' pressed add to minimum depth
else if (key == 'a') {
kinecter.minDepth = constrain(kinecter.minDepth + 10, 0, kinecter.thresholdRange);
println("minimum depth: " + kinecter.minDepth);
}
// z pressed subtract to minimum depth
else if (key == 'z') {
kinecter.minDepth = constrain(kinecter.minDepth - 10, 0, kinecter.thresholdRange);
println("minimum depth: " + kinecter.minDepth);
}
// s pressed add to maximum depth
else if (key == 's') {
kinecter.maxDepth = constrain(kinecter.maxDepth + 10, 0, kinecter.thresholdRange);
println("maximum depth: " + kinecter.maxDepth);
}
// x pressed subtract to maximum depth
else if (key == 'x') {
kinecter.maxDepth = constrain(kinecter.maxDepth - 10, 0, kinecter.thresholdRange);
println("maximum depth: " + kinecter.maxDepth);
}
// toggle showParticles on/off
else if (key == 'q') {
showParticles = !showParticles;
println("showing particles: " + showParticles);
}
// toggle showOpticalFlow on/off
else if (key == 'w') {
showOpticalFlow = !showOpticalFlow;
println("showing optical flow: " + showOpticalFlow);
}
// toggle showDepthImage on/off
else if (key == 'e') {
showDepthImage = !showDepthImage;
println("showing depth image: " + showDepthImage);
}
// different blend modes
else if (key == '1') {
depthImageBlendMode = BLEND;
println("Blend mode: BLEND");
}
else if (key == '2') {
depthImageBlendMode = ADD;
println("Blend mode: ADD");
}
else if (key == '3') {
depthImageBlendMode = SUBTRACT;
println("Blend mode: SUBTRACT");
}
else if (key == '4') {
depthImageBlendMode = DARKEST;
println("Blend mode: DARKEST");
}
else if (key == '5') {
depthImageBlendMode = LIGHTEST;
println("Blend mode: LIGHTEST");
}
else if (key == '6') {
depthImageBlendMode = DIFFERENCE;
println("Blend mode: DIFFERENCE");
}
else if (key == '7') {
depthImageBlendMode = EXCLUSION;
println("Blend mode: EXCLUSION");
}
else if (key == '7') {
depthImageBlendMode = MULTIPLY;
println("Blend mode: MULTIPLY");
}
else if (key == '8') {
depthImageBlendMode = SCREEN;
println("Blend mode: SCREEN");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment