本文整理汇总了Java中com.leapmotion.leap.Hand类的典型用法代码示例。如果您正苦于以下问题:Java Hand类的具体用法?Java Hand怎么用?Java Hand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Hand类属于com.leapmotion.leap包,在下文中一共展示了Hand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
}
示例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);
}
示例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();
}
示例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;
}
示例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();
}
示例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));
}
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
示例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());
}
示例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;
}
}
}
示例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);
}
}
}
}
示例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());
}