我想检查Leap Motion框架中的手是否当前为握拳状态。
通常建议的方法是查找hand.grabStrength
的值是否为1。问题在于,即使是“爪状”手或稍微弯曲的手指等都会将该值跳转为1。
另一种方法是检查每个手指是否extended
。但这也有类似的问题,只有完全伸直的手指才被计算为伸展状态。因此,即使我检查所有手指是否未伸展,仍然会出现与上述相同的问题(爪状手被识别为握住状态)。
结合这两种方法也无法解决问题,这并不奇怪,因为它们都存在相同的问题。
现在,我们可以获取每个手指的所有骨头,包括位置等。但是我不知道从哪里开始进行数学计算以检测手指是否弯曲。
基本上,我目前的设置如下:
var controller = Leap.loop(function(frame){
if(frame.hands.length>0){
//we only look at the first available hand
var hand = frame.hands[0];
//we get the index finger only, but later on we should look at all 5 fingers.
var index = hands.fingers[1];
//after that we get the positions of the joints between the bones in a hand
//the position of the metacarpal bone (i.e. the base of your hand)
var carp = index.carpPosition;
//the position of the joint on the knuckle of your hand
var mcp = index.mcpPosition;
//the position of the following joint, between the proximal and the intermediate bones
var pip = index.pipPosition;
//the position of the distal bone (the very tip of your finger)
var dip = index.dipPosition;
//and now we need the angle between each of those positions, which is where i'm stuck
}
});
那么,我如何获得这些位置之间的角度(从carp到mcp,从mcp到pip,从pip到dip)?有什么想法吗?