Sevenday pageviews

Feb 28, 2015

Leap Motion

Hey all,

As mentioned, this post is about the leap motion. Having studied about virtual reality, I have seen a lot of devices entering the playing field in the last couple of years. One of such devices is the leap motion. It is a well designed small box which uses three infrared lights and two cameras to detect your hands. Holding your hands above it (or in front of it when attached to a Head-Mounted-Device (HMD) like an Oculus rift for instance), you can use the leap as input for applications, games, etc.
However I don't think its tracking isn't robust enough to be used for casual users. But as software engineer it is actually fun to use and see what you can develop for it, so I took the "leap".

After installing the drivers and SDK, I checked out the app store. Eager to see if there is anything interesting on it. Most apps serve as tech demos and few actually offer something  useful or entertaining. So I decided to go right away to the development.
My idea is to develop a simple application that translates the hand position into mouse coordinates and have some gesture act as click. If I still think it's a good idea by the time the previous is implemented, I might add swipe recognition to be able to move the mouse between screens (toggling the mouse position from primary to secondary and back). The GUI framework I decided to go for, is WPF.

The SDK was simple enough to understand. It works similar to other hardware I've worked with. You subscribe to an event that sends frames, and use this as input for your application. A few obstacles however took some time to figure out, that's why I'd like to share them with you:
The first error I received, was the picture below.
























Not reading tutorials word by word, I apparently skipped the part in which they mention, you shouldn't just reference LeapCSharp.NET4.0.dll, but also copy Leap.dll and LeapCSharp.dll  in the debug folder. Things went smooth, and soon I got the mouse positioning working reasonably well, but when trying to play a game, the leap stopped responding...
It turns out that by default, leap only reacts when the application is active. So when you want to use the leap in your application, no matter if your application is active or on the background (minimized for instance), you can use the following line of code: "controller.SetPolicy(Controller.PolicyFlag.POLICY_BACKGROUND_FRAMES);".
Last but not least, WPF caused a problem because of its single-threaded design. Microsoft's "next-generation" presentation system makes multi-threaded applications more difficult to develop than winforms. However a solution to multi-threaded issues can be found here.

Well, that's it for today, I don't know when I can post again since this weekend will be all about doing and checking homework.

See you next time!



No comments:

Post a Comment