# Leap Motion Library problems

**URL:** <https://discourse.processing.org/t/leap-motion-library-problems/21401>\
**Category:** Libraries\
**Created:** [May 29, 2020, 1:37pm UTC](https://discourse.processing.org/t/leap-motion-library-problems/21401 "2020-05-29T13:37:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ablah](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@Ablah](https://discourse.processing.org/u/Ablah)\
**Post date:** [May 29, 2020, 1:37pm UTC](https://discourse.processing.org/t/leap-motion-library-problems/21401/1 "2020-05-29T13:37:39Z")

</div>

I’m trying to use the Leap Motion for school homework. I downloaded the library from Github and added it to the Processing Libraries.

I’m using:

- Processing 3.2.3
- Leap Motion Software 2.3.1+31549

At first, it seems to work fine, but after a while, it stops recognizing the hands. And the only way I found to make it work again is by restarting my computer (I’m using Windows 10). Still, if I use it for a while again, it stops recognizing.

Does anyone know how to fix it?

Here I’m using one of the examples given when downloading the library and I copy the code in case it helps.

**Working:**

[![](https://img.youtube.com/vi/xaRPl1qWX4s/maxresdefault.jpg "Leap Motion working") ](https://www.youtube.com/watch?v=xaRPl1qWX4s)

**Stopped working:**

[![](https://img.youtube.com/vi/G7BLIM_0Sgc/maxresdefault.jpg "Leap Motion stopped working after a while") ](https://www.youtube.com/watch?v=G7BLIM_0Sgc)

**Example code:**

```auto
import de.voidplus.leapmotion.*;

// ======================================================
// Table of Contents:
// ├─ 1. Callbacks
// ├─ 2. Hand
// ├─ 3. Arms
// ├─ 4. Fingers
// ├─ 5. Bones
// ├─ 6. Tools
// └─ 7. Devices
// ======================================================

LeapMotion leap;

void setup() {
  size(800, 500);
  background(255);
  // ...

  leap = new LeapMotion(this);
}

// ======================================================
// 1. Callbacks

void leapOnInit() {
  // println("Leap Motion Init");
}
void leapOnConnect() {
  // println("Leap Motion Connect");
}
void leapOnFrame() {
  // println("Leap Motion Frame");
}
void leapOnDisconnect() {
  // println("Leap Motion Disconnect");
}
void leapOnExit() {
  // println("Leap Motion Exit");
}

void draw() {
  background(255);
  // ...

  int fps = leap.getFrameRate();
  for (Hand hand : leap.getHands ()) {

    // ==================================================
    // 2. Hand

    int handId = hand.getId();
    PVector handPosition = hand.getPosition();
    PVector handStabilized = hand.getStabilizedPosition();
    PVector handDirection = hand.getDirection();
    PVector handDynamics = hand.getDynamics();
    float handRoll = hand.getRoll();
    float handPitch = hand.getPitch();
    float handYaw = hand.getYaw();
    boolean handIsLeft = hand.isLeft();
    boolean handIsRight = hand.isRight();
    float handGrab = hand.getGrabStrength();
    float handPinch = hand.getPinchStrength();
    float handTime = hand.getTimeVisible();
    PVector spherePosition = hand.getSpherePosition();
    float sphereRadius = hand.getSphereRadius();

    // --------------------------------------------------
    // Drawing
    hand.draw();

    // ==================================================
    // 3. Arm

    if (hand.hasArm()) {
      Arm arm = hand.getArm();
      float armWidth = arm.getWidth();
      PVector armWristPos = arm.getWristPosition();
      PVector armElbowPos = arm.getElbowPosition();
    }

    // ==================================================
    // 4. Finger

    Finger fingerThumb = hand.getThumb();
    // or hand.getFinger("thumb");
    // or hand.getFinger(0);

    Finger fingerIndex = hand.getIndexFinger();
    // or hand.getFinger("index");
    // or hand.getFinger(1);

    Finger fingerMiddle = hand.getMiddleFinger();
    // or hand.getFinger("middle");
    // or hand.getFinger(2);

    Finger fingerRing = hand.getRingFinger();
    // or hand.getFinger("ring");
    // or hand.getFinger(3);

    Finger fingerPink = hand.getPinkyFinger();
    // or hand.getFinger("pinky");
    // or hand.getFinger(4);

    for (Finger finger : hand.getFingers()) {
      // or hand.getOutstretchedFingers();
      // or hand.getOutstretchedFingersByAngle();

      int fingerId = finger.getId();
      PVector fingerPosition = finger.getPosition();
      PVector fingerStabilized = finger.getStabilizedPosition();
      PVector fingerVelocity = finger.getVelocity();
      PVector fingerDirection = finger.getDirection();
      float fingerTime = finger.getTimeVisible();

      // ------------------------------------------------
      // Drawing

      // Drawing:
      // finger.draw(); // Executes drawBones() and drawJoints()
      // finger.drawBones();
      // finger.drawJoints();

      // ------------------------------------------------
      // Selection

      switch(finger.getType()) {
      case 0:
        // System.out.println("thumb");
        break;
      case 1:
        // System.out.println("index");
        break;
      case 2:
        // System.out.println("middle");
        break;
      case 3:
        // System.out.println("ring");
        break;
      case 4:
        // System.out.println("pinky");
        break;
      }

      // ================================================
      // 5. Bones
      // --------
      // https://developer.leapmotion.com/documentation/java/devguide/Leap_Overview.html#Layer_1

      Bone boneDistal = finger.getDistalBone();
      // or finger.get("distal");
      // or finger.getBone(0);

      Bone boneIntermediate = finger.getIntermediateBone();
      // or finger.get("intermediate");
      // or finger.getBone(1);

      Bone boneProximal = finger.getProximalBone();
      // or finger.get("proximal");
      // or finger.getBone(2);

      Bone boneMetacarpal = finger.getMetacarpalBone();
      // or finger.get("metacarpal");
      // or finger.getBone(3);

      // ------------------------------------------------
      // Touch emulation

      int touchZone = finger.getTouchZone();
      float touchDistance = finger.getTouchDistance();

      switch(touchZone) {
      case -1: // None
        break;
      case 0: // Hovering
        // println("Hovering (#" + fingerId + "): " + touchDistance);
        break;
      case 1: // Touching
        // println("Touching (#" + fingerId + ")");
        break;
      }
    }

    // ==================================================
    // 6. Tools

    for (Tool tool : hand.getTools()) {
      int toolId = tool.getId();
      PVector toolPosition = tool.getPosition();
      PVector toolStabilized = tool.getStabilizedPosition();
      PVector toolVelocity = tool.getVelocity();
      PVector toolDirection = tool.getDirection();
      float toolTime = tool.getTimeVisible();

      // ------------------------------------------------
      // Drawing:
      // tool.draw();

      // ------------------------------------------------
      // Touch emulation

      int touchZone = tool.getTouchZone();
      float touchDistance = tool.getTouchDistance();

      switch(touchZone) {
      case -1: // None
        break;
      case 0: // Hovering
        // println("Hovering (#" + toolId + "): " + touchDistance);
        break;
      case 1: // Touching
        // println("Touching (#" + toolId + ")");
        break;
      }
    }
  }

  // ====================================================
  // 7. Devices

  for (Device device : leap.getDevices()) {
    float deviceHorizontalViewAngle = device.getHorizontalViewAngle();
    float deviceVericalViewAngle = device.getVerticalViewAngle();
    float deviceRange = device.getRange();
  }
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [June 3, 2020, 3:36pm UTC](https://discourse.processing.org/t/leap-motion-library-problems/21401/2 "2020-06-03T15:36:45Z")

</div>

@Ablah – were you able to resolve this issue?

Sorry that I do not have a Leap Motion on hand to test this.

---

<div class="post-metadata">

**Author:** ![laererlund](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laererlund/32/10708_2.png) [@laererlund](https://discourse.processing.org/u/laererlund)\
**Post date:** [September 28, 2020, 6:12pm UTC](https://discourse.processing.org/t/leap-motion-library-problems/21401/3 "2020-09-28T18:12:41Z")

</div>

Hi - I have had a similar, or at least probably related, problem just now. See [this post](https://discourse.processing.org/t/processing-does-not-find-device/24193)

What works for me is \<_deleted_\>

_edit - sorry, starting the sketch before plugging in the LEAP didn’t work reliably. What seems to work is to upgrade the SDK to version 3.2.1, as stated in my reply to the post menitioned above. Newer versions did not work for me, at least not at first try_

---

<div class="post-metadata">

**Author:** ![seemang](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@seemang](https://discourse.processing.org/u/seemang)\
**Post date:** [May 23, 2022, 7:57pm UTC](https://discourse.processing.org/t/leap-motion-library-problems/21401/4 "2022-05-23T19:57:28Z")

</div>

I’ve had the same issues sometimes, Try wait a few seconds it will show up. 😀
