如何解决LeapJS 的 Leap Motion 手势检测精度
我在我的节点应用程序中使用跳跃运动传感器来检测手势。使用我当前的设置,手势检测可以正常工作,但没有我需要的那么准确。当我执行滑动手势时,跳跃运动并不总是发送滑动手势对象,当它检测到滑动时,它通常会发送多个手势。例如,当向左滑动时,它将返回向左滑动和向上滑动。我想知道这是否是我的代码或我的跳跃运动传感器的问题。
这是我的跳跃控制代码:
var controller = Leap.loop({ inNode: true,enableGestures: true },function(frame) {
// finger location tracking
if(frame.hands.length > 0) {
var iBox = frame.interactionBox;
var pointable = frame.pointables[0];
if (pointable) {
var leapPoint = pointable.stabilizedTipPosition;
var normalizedPoint = iBox.normalizePoint(leapPoint,true);
let mouseControlY = (1 - normalizedPoint[1]) * appHeight; // with leap facing up
// invert directions for mirror
let invertMouseControlX = (1 - normalizedPoint[0]) * appWidth;
updateMouseCords(invertMouseControlX,mouseControlY)
}
}
// finger gesture tracking
if(frame.valid && frame.gestures.length > 0){
frame.gestures.forEach(function(gesture){
switch (gesture.type){
case "screenTap":
console.log("Click");
break;
case "swipe":
handleSwipe(gesture);
break;
}
});
}
});
function handleSwipe (swipe) {
let io = getIO();
if(swipe.state === 'stop'){
if (swipe.direction[0] > 0){
// user swiped right
swipeDirection = 'right'
} else {
// user swiped left
swipeDirection = 'left'
}
if(swipe.direction[1] > 0) {
// user swiped up
swipeDirection = 'up'
}
// send swipe direction to frontend
io.emit('swipeData',swipeDirection);
}
}
我只需要检测向左、向右或向上滑动以及可能的屏幕点击手势。我可以做些什么来优化我的代码,或者问题可能是我的传感器?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。