我想实现一种鼓。对于每首歌曲,我都想播放一首歌。所以我需要检测每一个“命中”和位置。在我开始实现将分析位置并检测“命中”的功能之前,我想确定没有其他解决方案,那么是否有任何事件,手势检测允许我检测到呢?
问问题
1207 次
2 回答
1
据我所知,除了流回调之外,没有本地定义的“事件”,当您接收到关节位置和深度图像等数据时调用它应该足以让您入门。
我会看看这个:https ://code.google.com/p/kineticspace/以了解会发生什么或如何继续使用您自己的代码。
一旦你设法获得骨架数据,只需找到当时手的位置,为其位置设置一个阈值并开始跟踪一段时间,看看它的移动路径是否适合你的特定手势模式,例如“翻译y 方向 x 秒数”。然后你就有了非常简单的“击中”手势检测。这可以根据您的需要变得复杂,但就您从图书馆方面收到的内容而言,基础知识并不多。
祝你好运。
于 2014-06-08T23:51:38.520 回答
0
我使用 Kinect 制作了一个架子鼓,这是在 Kinect 中放置和使用盒子的精彩课程。导入库:
import processing.opengl.*;
import SimpleOpenNI.*;
在 Setup() 中使用类似这段代码的东西
myTrigger = new Hotpoint(200, 10, 800, size);
使用 draw() 中的方法
if(myTrigger.currentlyHit()) {
myTrigger.play();
println("trigger hit");
}
在这个类中使用以下方法!
class Hotpoint {
PVector center;
color fillColor;
color strokeColor;
int size;
int pointsIncluded;
int maxPoints;
boolean wasJustHit;
int threshold;
Hotpoint(float centerX, float centerY, float centerZ, int boxSize) {
center = new PVector(centerX, centerY, centerZ);
size = boxSize;
pointsIncluded = 0;
maxPoints = 1000;
threshold = 0;
fillColor = strokeColor = color(random(255), random(255), random(255));
}
void setThreshold( int newThreshold ){
threshold = newThreshold;
}
void setMaxPoints(int newMaxPoints) {
maxPoints = newMaxPoints;
}
void setColor(float red, float blue, float green){
fillColor = strokeColor = color(red, blue, green);
}
boolean check(PVector point) {
boolean result = false;
if (point.x > center.x - size/2 && point.x < center.x + size/2) {
if (point.y > center.y - size/2 && point.y < center.y + size/2) {
if (point.z > center.z - size/2 && point.z < center.z + size/2) {
result = true;
pointsIncluded++;
}
}
}
return result;
}
void draw() {
pushMatrix();
translate(center.x, center.y, center.z);
fill(red(fillColor), blue(fillColor), green(fillColor),
255 * percentIncluded());
stroke(red(strokeColor), blue(strokeColor), green(strokeColor), 255);
box(size);
popMatrix();
}
float percentIncluded() {
return map(pointsIncluded, 0, maxPoints, 0, 1);
}
boolean currentlyHit() {
return (pointsIncluded > threshold);
}
boolean isHit() {
return currentlyHit() && !wasJustHit;
}
void clear() {
wasJustHit = currentlyHit();
pointsIncluded = 0;
}
}
于 2015-10-12T17:56:04.963 回答