Leap Motion

来源:互联网 发布:淘宝低价风险交易 编辑:程序博客网 时间:2024/03/29 23:24

1、坐标系

这里写图片描述

2、手

这里写图片描述

3、Fingers

这里写图片描述

4、Gestures 四种: Circle、Swipe、Key Tap、Screen Tap

1)Circle
这里写图片描述

属性:center、duration、handIds、id、normal、pointableIds、progress、radius、state、type

2) Swipe 多两个属性:speed 、startPosition
这里写图片描述

判断滑动方向:
var controllerOptions = {enableGestures: true};Leap.loop(controllerOptions, function(frame) {  // Display Gesture object data  if (frame.gestures.length > 0) {    for (var i = 0; i < frame.gestures.length; i++) {      var gesture = frame.gestures[i];      if(gesture.type == "swipe") {          //Classify swipe as either horizontal or vertical          var isHorizontal = Math.abs(gesture.direction[0]) > Math.abs(gesture.direction[1]);          //Classify as right-left or up-down          if(isHorizontal){              if(gesture.direction[0] > 0){                  swipeDirection = "right";              } else {                  swipeDirection = "left";              }          } else { //vertical              if(gesture.direction[1] > 0){                  swipeDirection = "up";              } else {                  swipeDirection = "down";              }                            }          console.log(swipeDirection)       }     }  }});

3)Key Tap
这里写图片描述

4)Screen Tap
这里写图片描述

手势判断代码:

var controller = Leap.loop({enableGestures: true}, function(frame){  if(frame.valid && frame.gestures.length > 0){    frame.gestures.forEach(function(gesture){        switch (gesture.type){          case "circle":              console.log("Circle Gesture");              break;          case "keyTap":              console.log("Key Tap Gesture");              break;          case "screenTap":              console.log("Screen Tap Gesture");              break;          case "swipe":              console.log("Swipe Gesture");              break;        }    });  }});
KeyTapGesture、ScreenTapGesture、SwipeGesture都拥有属性:
  • duration
  • handIds
  • id
  • pointableIds
  • state
  • type
  • direction
  • position

5、Motions:Scale、Rotation、Translation

Leap 可以根據每幀和前幀檢測到的數據,生成運動信息。例如,

若檢測到兩隻手,並且兩隻手都超一個方向移動,就認爲是平移;
若是像握着球一樣轉動,則記爲旋轉。
若兩隻手靠近或分開,則記爲縮放。

所生成的數據包含:
  • 旋轉的軸向向量;
  • 旋轉的角度(順時針爲正);
  • 描述旋轉的矩陣;
  • 縮放因子;
  • 平移向量;
對於每隻手,可以檢測到如下信息:
  • 手掌中心的位置(三維向量,相對於傳感器座標原點,毫米爲單位);
  • 手掌移動的速度(毫米每秒);
  • 手掌的法向量(垂直於手掌平面,從手心指向外);
  • 手掌朝向的方向;
  • 根據手掌彎曲的弧度確定的虛擬球體的中心;
  • 根據手掌彎曲的弧度確定的虛擬球體的半徑;
当设备检测到手、手指、工具或者是手势的话,设备会赋予它一个唯一的ID号码作为标记,只要这个实体不出设备的可视区域,这个ID号就会一直不变,如果设备丢失这个实体之后又出现了,Leap 就会赋予它一个新的ID号码,但是软件不会知道这个和以前的那个实体有什么关系。

建议在Leap Motion Controller的视野中至多保留两只手,以获得最佳的运动跟踪质量。

原创粉丝点击