Demo entry 6365462

LeapMotion手势信息

   

Submitted by anonymous on May 19, 2017 at 12:45
Language: JavaScript. Code size: 1.2 kB.

	//LeapMotion控制器的事件监听器,获取手势frame信息
   	leapMotionController.on("frame", function(frame) { 	  
          if(frame.hands.length>0){	  
   	  var hand = frame.hands[0];	//LeapMotion手对象 
         
          var handNormal = {};	//手掌掌心向外正方向
          handNormal.x = hand.palmNormal[0];
          handNormal.y = hand.palmNormal[1];
          handNormal.z = hand.palmNormal[2];

          var handFront = {};	//手掌五指指向方向
          handFront.x = hand.direction[0];
          handFront.y = hand.direction[1];
          handFront.z = hand.direction[2];

          var convert = (180/math.pi);
   	  	  //控制左右水平移动,根据手掌左右倾斜判断移动方向
          var left_right = math.atan(handNormal.x/handNormal.x) * convert;
   	  	  //控制前后水平移动,根据手掌前后倾斜判断移动方向
          var front_back = math.atan(handNormal.z/handNormal.x) * convert;
   	  	  //控制飞行方向,根据手掌指向移动无人机指向
          var head_direction = -( math.atan(handFront.x/handFront.z) * convert );  	  					
		  //手势模式
   	  	  if(serverMode == 0){
			var threshold = 30;		//操作阈值
			 /*
			 *	根据left_right,front_back,head_direction以及hand.grabStrength四个参数
			 *	和阈值比较,形成操作指令
			 */
			 ......
		  }
	  }
	}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).