• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Hand类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.leapmotion.leap.Hand的典型用法代码示例。如果您正苦于以下问题:Java Hand类的具体用法?Java Hand怎么用?Java Hand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Hand类属于com.leapmotion.leap包,在下文中一共展示了Hand类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onFrame

import com.leapmotion.leap.Hand; //导入依赖的package包/类
@Override
public void onFrame(Controller controller) {
	LeapData data = new LeapData();
	// The old publishFrame method for those who want it.
	data.frame = controller.frame();
	myService.invoke("publishFrame", data.frame);
	// grab left/right hands
	Hand lh = controller.frame().hands().leftmost();
	Hand rh = controller.frame().hands().rightmost();
	// map the data to the MRL Hand pojo
	LeapMotion2.Hand mrlLHand = mapLeapHandData(lh);
	LeapMotion2.Hand mrlRHand = mapLeapHandData(rh);
	// set them to the LeapData obj
	data.leftHand = mrlLHand;
	data.rightHand = mrlRHand;
	// Grab the current frame
	// Track the last valid data frame.
	// TODO: test and make sure this is worky?
	if (data.frame.isValid()) {
		myService.lastLeapData = data;
		// only publish valid frames ?
		myService.invoke("publishLeapData", data);
	}

}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:26,代码来源:LeapMotionListener.java


示例2: onFrame

import com.leapmotion.leap.Hand; //导入依赖的package包/类
public void onFrame(Controller controller)
{
  Frame frame = controller.frame();

  GestureList gestures = frame.gestures();

  for (Gesture gesture : gestures)
  {
    processGestureEvent(gesture);
  }

  if (frame.hands().isEmpty())
  {
    processNoDetectionEvent();
  } else
  {
    Hand hand = frame.hands().get(0);
    processDetectionEvent(hand);
  }
}
 
开发者ID:theone1984,项目名称:parroteer,代码行数:21,代码来源:LeapMotionListener.java


示例3: getDetectionData

import com.leapmotion.leap.Hand; //导入依赖的package包/类
public DetectionData getDetectionData(Hand hand)
{
  // Get the hand's normal vector and direction
  Vector normal = hand.palmNormal();
  Vector direction = hand.direction();

  float pitch = ((Double) Math.toDegrees(direction.pitch())).floatValue()
          / MAX_PITCH;
  float roll = ((Double) Math.toDegrees(normal.roll())).floatValue()
          / MAX_ROLL;
  float yaw = ((Double) Math.toDegrees(direction.yaw())).floatValue()
          / MAX_YAW;
  float height = hand.palmPosition().getY() / MAX_HEIGHT;

  return new DetectionData(roll, pitch, yaw, height);
}
 
开发者ID:theone1984,项目名称:parroteer,代码行数:17,代码来源:LeapMotionListener.java


示例4: HandShape

import com.leapmotion.leap.Hand; //导入依赖的package包/类
/**
 * Constructs a hand shape from the Hand object
 * 
 * @param hand
 *            the hand to construct the hand shape from
 */
public HandShape(Hand hand) {
	if (hand.isLeft()) {
		this.data.handSide = LEFT;
	} else {
		this.data.handSide = RIGHT;
	}
	this.data.fingerPositions = new Vector[hand.fingers().count()];
	for (int i = 0; i < data.fingerPositions.length; i++) {
		data.fingerPositions[i] = hand.fingers().get(i).tipPosition();
	}
	this.data.palmLocation = hand.palmPosition();
	// this.data.handBasis = hand.basis();
	this.data.palmDirection = hand.palmNormal();
}
 
开发者ID:npw3202,项目名称:ASL-recognition,代码行数:21,代码来源:HandShape.java


示例5: mapLeapHandData

import com.leapmotion.leap.Hand; //导入依赖的package包/类
private LeapMotion2.Hand mapLeapHandData(Hand lh) {
	LeapMotion2.Hand mrlHand = new LeapMotion2.Hand();
	// process the normal
	Vector palmNormal = lh.palmNormal();
	mrlHand.palmNormalX = palmNormal.getX();
	mrlHand.palmNormalY = palmNormal.getY();
	mrlHand.palmNormalZ = palmNormal.getZ();

	// handle the fingers.
	for (Finger.Type t : Finger.Type.values()) {
		Finger f = lh.fingers().get(t.ordinal());
		double angle = computeAngleDegrees(f, palmNormal);
		if (t.equals(Finger.Type.TYPE_INDEX))
			mrlHand.index = angle;
		else if (t.equals(Finger.Type.TYPE_MIDDLE))
			mrlHand.middle = angle;
		else if (t.equals(Finger.Type.TYPE_RING))
			mrlHand.ring = angle;
		else if (t.equals(Finger.Type.TYPE_PINKY))
			mrlHand.pinky = angle;
		else if (t.equals(Finger.Type.TYPE_THUMB))
			mrlHand.thumb = angle;
		else
			log.warn("Unknown finger! eek..");
	}
	return mrlHand;
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:28,代码来源:LeapMotionListener.java


示例6: HandObj

import com.leapmotion.leap.Hand; //导入依赖的package包/类
public HandObj(Hand h, FrameObj f, ControllerObj controller) {
	this.controller = controller;
	//fingerList = new FingerListObj(h.fingers());
	//pointableList = new PointableListObj(h.pointables());
	
	arm = new ArmObj(h.arm());
	
	confidence = h.confidence();
	direction = h.direction();
	//elbow
	frame = f;
	grabStrength = h.grabStrength();
	id = h.id();
	palmNormal = h.palmNormal();
	palmPosition = h.palmPosition();
	palmVelocity = h.palmVelocity();
	palmWidth = h.palmWidth();
	pinchStrength = h.pinchStrength();
	//r
	//s
	sphereCenter = h.sphereCenter();
	sphereRadius = h.sphereRadius();
	stabilizedPalmPosition = h.stabilizedPalmPosition();
	//t
	timeVisible = h.timeVisible();
	
	if (h.isLeft()) {
		type = "left";
	} else {
		type = "right";
	}
	
	wrist = h.wristPosition();
	
	
}
 
开发者ID:paluka,项目名称:Multi-Leap,代码行数:37,代码来源:HandObj.java


示例7: HandListObj

import com.leapmotion.leap.Hand; //导入依赖的package包/类
/**
 * Constructs an list of hands from the provided list.
 */
public HandListObj(HandList list, FrameObj frame, ControllerObj controller) {
	hands = new ArrayList<HandObj>();
	this.controller = controller;
	
	for (Hand h : list) {
		hands.add(new HandObj(h, frame, controller));
	}
	
	
}
 
开发者ID:paluka,项目名称:Multi-Leap,代码行数:14,代码来源:HandListObj.java


示例8: mapLeapHandData

import com.leapmotion.leap.Hand; //导入依赖的package包/类
private LeapHand mapLeapHandData(Hand lh) {
  LeapHand mrlHand = new LeapHand();
  // process the normal
  Vector palmNormal = lh.palmNormal();
  mrlHand.palmNormalX = palmNormal.getX();
  mrlHand.palmNormalY = palmNormal.getY();
  mrlHand.palmNormalZ = palmNormal.getZ();

  mrlHand.posX = lh.arm().center().getX();
  mrlHand.posY = lh.arm().center().getY();
  mrlHand.posZ = lh.arm().center().getZ();

  // handle the fingers.
  for (Finger.Type t : Finger.Type.values()) {
    Finger f = lh.fingers().get(t.ordinal());
    int angle = (int) computeAngleDegrees(f, palmNormal);
    if (t.equals(Finger.Type.TYPE_INDEX))
      mrlHand.index = angle;
    else if (t.equals(Finger.Type.TYPE_MIDDLE))
      mrlHand.middle = angle;
    else if (t.equals(Finger.Type.TYPE_RING))
      mrlHand.ring = angle;
    else if (t.equals(Finger.Type.TYPE_PINKY))
      mrlHand.pinky = angle;
    else if (t.equals(Finger.Type.TYPE_THUMB))
      mrlHand.thumb = angle;
    else
      log.warn("Unknown finger! eek..");
  }
  return mrlHand;
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:32,代码来源:LeapMotionListener.java


示例9: translationGesture

import com.leapmotion.leap.Hand; //导入依赖的package包/类
private boolean translationGesture(Frame latestFrame, Frame refFrame) {
	float t_prob;
	Hand la_handl, la_handr;
	Hand re_handl, re_handr;
	
	if ((latestFrame.hands().count() == 2) && (refFrame.hands().count() == 2)) {
		la_handl = latestFrame.hands().leftmost();
		la_handr = latestFrame.hands().rightmost();
		re_handl = refFrame.hands().leftmost();
		re_handr = refFrame.hands().rightmost();

		if (areClose(la_handl, la_handr)
				&& areClose(re_handl, re_handr)
				&& la_handl.id() == re_handl.id()
				&& la_handr.id() == re_handr.id()
				&& (t_prob = latestFrame.translationProbability(refFrame)) > LeapMotionListenerC.confidence_threshold_translation) {
			Vector translation = latestFrame.translation(refFrame);

			for (LeapMotionObserver observer : observers)
				observer.onTranslation(translation.getX(), translation.getY());

			System.out.println(LeapMotionListenerC.onTranslation + " x: "
					+ translation.getX() + ", y: " + translation.getY()
					+ ", prob: " + t_prob);

			return true;
		}
	}
	
	return false;
}
 
开发者ID:valenbg1,项目名称:protoboard,代码行数:32,代码来源:LeapMotionListener.java


示例10: onInit

import com.leapmotion.leap.Hand; //导入依赖的package包/类
public void onInit(Controller controller) {
	// Initialize arrays
	for (int i = 0; i < hands.length; i++)
		hands[i] = new Hand();
	for (int i = 0; i < tools.length; i++)
		tools[i] = new Tool();
	for (int i = 0; i < fingers.length; i++)
		fingers[i] = new Finger();
}
 
开发者ID:khanning,项目名称:LeapScratch,代码行数:10,代码来源:LeapListener.java


示例11: processDetectionEvent

import com.leapmotion.leap.Hand; //导入依赖的package包/类
public void processDetectionEvent(Hand hand)
{
  DetectionData detectionData = getDetectionData(hand);
  logger.trace(String
          .format("Detected a hand - roll: %.2f, pitch: %.2f, yaw: %.2f, height: %.2f",
                  detectionData.getRoll(), detectionData.getPitch(),
                  detectionData.getYaw(), detectionData.getHeight()));

  for (DetectionListener listener : detectionListeners)
  {
    listener.onDetect(detectionData);
  }
}
 
开发者ID:theone1984,项目名称:parroteer,代码行数:14,代码来源:LeapMotionListener.java


示例12: strenght

import com.leapmotion.leap.Hand; //导入依赖的package包/类
public void strenght(Controller controller) {
	Frame frame = controller.frame();
	Hand hand = frame.hands().rightmost();
	System.out.println("Strenght is: " + hand.grabStrength());

}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:7,代码来源:SampleListener.java


示例13: onFrame

import com.leapmotion.leap.Hand; //导入依赖的package包/类
@Override
public void onFrame(Controller controller) {
    Frame frame = controller.frame();
    if (!frame.hands().isEmpty()) {
        numHands.set(frame.hands().count());
        Screen screen = controller.locatedScreens().get(0);
        if (screen != null && screen.isValid()){
            Hand hand;
            if(numHands.get()>1){
                hand=frame.hands().leftmost();
            } else {
                hand=frame.hands().get(0);
            }
            z1.set(hand.palmPosition().getZ());
            pitchLeftAverage.add(new Double(hand.direction().pitch()));
            rollLeftAverage.add(new Double(hand.palmNormal().roll()));
            yawLeftAverage.add(new Double(hand.direction().yaw()));                   
            pitchLeft.set(dAverage(pitchLeftAverage));
            rollLeft.set(dAverage(rollLeftAverage));
            yawLeft.set(dAverage(yawLeftAverage));

            Vector intersect = screen.intersect(hand.palmPosition(),hand.direction(), true);
            posLeftAverage.add(intersect);
            Vector avIntersect=vAverage(posLeftAverage);
            posHandLeft.setValue(new Point3D(screen.widthPixels()*Math.min(1d,Math.max(0d,avIntersect.getX())),
                    screen.heightPixels()*Math.min(1d,Math.max(0d,(1d-avIntersect.getY()))),
                    hand.palmPosition().getZ()));
        }               
    }
    
    GestureList gestures = frame.gestures();
    for (int i = 0; i < gestures.count(); i++) {
        Gesture gesture = gestures.get(i);
        if(gesture.type()==Type.TYPE_CIRCLE){
            CircleGesture cGesture = new CircleGesture(gesture);
            if(numHands.get()>1){
                for(Hand h:cGesture.hands()){
                    if(h.equals(frame.hands().rightmost())){
                        circle.set(cGesture);
                        break;
                    }
                }
            }
            break;
        }
    }
}
 
开发者ID:jperedadnr,项目名称:Leap3DFX,代码行数:48,代码来源:SimpleLeapListener.java


示例14: onFrame

import com.leapmotion.leap.Hand; //导入依赖的package包/类
@Override
public void onFrame(Controller controller) {
  LeapData data = new LeapData();
  // The old publishFrame method for those who want it.
  data.frame = controller.frame();
  myService.invoke("publishFrame", data.frame);
  // grab left/right hands

  Hand lh = controller.frame().hands().leftmost();
  Hand rh = controller.frame().hands().rightmost();
  // map the data to the MRL Hand pojo

  LeapHand mrlLHand = null;
  LeapHand mrlRHand = null;
  if (lh.isLeft()) {
    mrlLHand = mapLeapHandData(lh);
  }
  if (lh.isRight()) {
    mrlRHand = mapLeapHandData(rh);
  }
  // set them to the LeapData obj
  data.leftHand = mrlLHand;
  data.rightHand = mrlRHand;
  // Grab the current frame
  // Track the last valid data frame.
  // TODO: test and make sure this is worky?
  if (data.frame.isValid()) {
    numFrames++;
    myService.lastLeapData = data;
    // only publish valid frames ?
    myService.invoke("publishLeapData", data);

    ArrayList<Point> points = new ArrayList<Point>();
    for (Hand h : data.frame.hands()) {
      // position infomration
      double x = h.arm().center().getX();
      double y = h.arm().center().getY();
      double z = h.arm().center().getZ();
      // orientation information
      double roll = h.palmNormal().roll();
      double pitch = h.palmNormal().pitch();
      double yaw = h.palmNormal().yaw();
      // create the point to publish
      Point palmPoint = new Point(x, y, z, roll, pitch, yaw);
      ;
      // add it to the list of points we publish
      points.add(palmPoint);
    }
    // publish the points.
    if (points.size() > 0) {
      // TODO: gotta down sample for ik3d to keep up.
      if (numFrames % 20 == 0) {
        myService.invoke("publishPoints", points);
      }
    }

  }

}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:60,代码来源:LeapMotionListener.java


示例15: strenght

import com.leapmotion.leap.Hand; //导入依赖的package包/类
public void strenght(Controller controller) {
  Frame frame = controller.frame();
  Hand hand = frame.hands().rightmost();
  System.out.println("Strenght is: " + hand.grabStrength());

}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:7,代码来源:SampleListener.java


示例16: areClose

import com.leapmotion.leap.Hand; //导入依赖的package包/类
private boolean areClose(Hand handl, Hand handr) {
	return handr.palmPosition().minus(handl.palmPosition()).magnitude() <= LeapMotionListenerC.palms_near_threshold;
}
 
开发者ID:valenbg1,项目名称:protoboard,代码行数:4,代码来源:LeapMotionListener.java



注:本文中的com.leapmotion.leap.Hand类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PathElement类代码示例发布时间:2022-05-21
下一篇:
Java Agent类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap