Leap Motion Top Down Tracking (Policy flag) - (Resolved)


I have written an application in processing using Leap motion and everything works perfectly when testing on the desk with the leap the normal way up. The moment I try to use it top mounted (the intended usage scenario for product) it no longer detects gestures. Obviously if I flip my hands over it works fine but this is very counter intuitive and no good.

I am hoping that if I could set the policy flag to optimize HMD /Top down that this would resolve my issues, however I cannot figure out how I would go about doing this.

The Java implementation to set the policy flag is documented here: Leap Motion Java Docs

Any help is much appreciated. Will


  • What library are you using (if any)? Any code to show?

  • Thats for responding!

    The libraries I am using are: Leap Motion (by Michael Heuer) LeapMotionP5

    The reason for using two is simply because they both offered different features exclusive to themselves.

    I can provide code but I am not really sure what code exactly would help? (I'd rather not post the whole sketch as most of it is irrelevant and its quite long).

  • Using the Leap Motion library, this is how you set a policy flag:

    import com.leapmotion.leap.Controller;
    import com.leapmotion.leap.processing.LeapMotion;
    import com.leapmotion.leap.Controller.PolicyFlag;
    LeapMotion leap;
    void setup()
      leap = new LeapMotion(this);
    //This method gets called when the Leap is initialized
    void onInit(final com.leapmotion.leap.Controller controller)
      //This is important as it causes the Leap Motion to keep on sending data when the window isn't active anymore

    You could try to use the POLICY_OPTIMIZE_HMD policy flag.

  • I got very excited when I saw this as I it looks to be exactly what I am after however when I tried to use with POLICY_OPTIMIZE_HMD I get an error.

    Cannot find anything named "com.leapmotion.leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD"

    Is this likely to be due to not being implemented in the library or can I resolve myself?

    Thanks, Will

  • I have found a possible hack that might work to allow HMD if you do not think I could resolve this within processing (I'll await feedback).

    In the known issues on the leap motion API version changes page. It cites:

    • Minimized or out-of-focus applications using the HMD policy flag can affect the service state. Close such programs before switching back to non-VR apps.

    This could potentially mean I could run another app in the background that does nothing but change the policy flag.

  • No, that doesn't sound like a good solution.

    It's been a while since I used the LeapMotion library so it's likely something changed or I messed up between the two libraries. That means the com.leapmotion.leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD is likely wrong, as in it could be located elsewhere in the packages. You can try looking in the javadoc of the library you want to use for the policy flag. Maybe you need to set it for both libraries.

  • Ye it definitely wouldn't be an ideal solution. And a bodge at best (I also tested it with javascript and it didn't have any effect on the processing sketch running so my logic is flawed!)

    The POLICY_BACKGROUND_FRAMES, code you posted runs and works (which is useful anyway) but suggests to me maybe the library hasn't been updated to included HMD policy?

  • Is the HMD policy a recent addition? (I'm not quite up to date with Leap development). You could try to request an update from the library programmers...

  • edited October 2014

    Yes the HMD is fairly recent, it is to go with the V2 software leap motion recently submitted for public release to aid virtual reality uses when mounted to an Oculus Rift.

    I might try to request it but I fear that they may no longer be updating as from what I can see on github the last update was quite a while ago from both library programmers.

    Edit: Having said this I have just checked Github and looks like in the past 2 days one of the libraries has been updated, I will report back if I get anywhere with a request! :)

  • So to update this, I did indeed get somewhere with a request from the library programmer. Michael Heuer who has been very helpful! https://github.com/heuermh/leap-motion-processing He even added an example sketch to demonstrate its usage, I am still having issues getting it to work but believe it must be to do with my system (SDK, Java or Processing) if its working for others.

  • Hey, I am sorry for bumping up the thread but did you ever find a solution? I am still not getting support for HMD mode. I even made an issue on heuermh's github.

Sign In or Register to comment.