The Leap Motion is a sensor device that supports hand and finger motions as input, analogous to a mouse, but requires no hand contact or touching.
In other words, it’s like Kinect for hands only.
Leap Motion is a really smart and small device which looks like below.

I’ve some experience with this device and before I will describe you more how it works and why it’s worth to buy it let me show you one of my games.

The Maze – my way to make hands rehabilitation easier

I created a simple 2D game, where the player has to come to the indicated place by using hand. The goal of this game was to help the people (mainly children) with hands disabilities during the rehabilitation. In most cases, the standard rehabilitation is very hard and boring for children and I believe that my simple game may help in this case. See the result on the attached movie.

As you can see the game looks really simple, but the most important fact is, that the player has to use the wrist. This game was created in consultation with a physiotherapist and is still use in a special school for children with disabilities in Kraków. I’m very proud of that.

How was this game created?

The Leap Motion support a lot of languages like C++, Java, Python, JavaScript or even Objective-C. Of course, u can use Unity and Unreal Engine for creating some more sophisticated apps.
I chose JavaScipt. Why? I was very curious how this device works and how to use it during developments. I know JavaScript quite well so I could start to write my apps quite fast. I also wanted to make games which will be extra easy to run without any installations etc., just plug in the device, going for proper URL and that’s it.
The API for every language is really wide and great described in official docs. The developers made an awesome job!

First of all I had to implement algorithm for creating the “perfect” maze, it means, that the players is able to visit every single place in the maze. I implemented the “Recursive Backtracker” algorithm, which is quite easy to implement but still efficient.
The algorithm describerd in Wikipedia, sounds like that:

  1. Make the initial cell the current cell and mark it as visited
  2. While there are unvisited cells
    1. If the current cell has any neighbours which have not been visited
      1. Choose randomly one of the unvisited neighbours
      2. Push the current cell to the stack
      3. Remove the wall between the current cell and the chosen cell
      4. Make the chosen cell the current cell and mark it as visited
    2. Else if stack is not empty
      1. Pop a cell from the stack
      2. Make it the current cell

The Leap Motion allows to distinguish every part of hand bones and all of them is available in the API. I used this functionality to calculate the position difference between Distal phalanges and Carpals (see the image below). Thanks to these calculations I was able to determinate the pointer direction.

Ok… but how it works?

Under the hood, the Leap Motion is almost the same as Kinect.
The heart of the device consists of two cameras and three infrared LEDs. These track infrared light with a wavelength of 850 nanometers, which is outside the visible light spectrum. The collected data is streamed via USB to the Leap Motion tracking software. What’s interesting, thanks to USB 3.0, the range of device increased from 60cm to 80cm, cause of greater voltage.
The power of this device is sophisticated software. When data comes, then some heavy mathematical computation starts. Leap Motion doesn’t generate a depth map, it work’s on the raw sensor data.
The whole software and hardware description is a topic for another post, so let me know if you want to read more about that.

My opinion about Leap Motion Controller

For sure Leap Motion is a solid and good looking device. My very first experience was really good. Unfortunately, after test with some free demo applications, my feelings were slightly worse.
First of all, the controller doesn’t track the hands very well. The biggest problems occur with fingers, which really often are arranged differently on the display and in reality. What’s more, the range of the device isn’t as good as we can imagine, we have to keep hands quite narrow.
The situation is different when we use the Leap Motion Controller like a pointer. In this case, it works like a charm! We can easily replace the standard mouse with the controller, the pointer is really precise, even better than I thought.

The big problem with this device is a small thing… the hands kept over the controller hurt after 20 minutes… really!

From the developer perspective, it’s more than awesome. First of all the Leap Motion supports a lot of languages so you can choose your favorite. What’s more, the documentation covers every important topic, so you can easily and quickly start to write some code.


If you ever wanted to create an application for Xbox Kinect or other similar devices, you should buy Leap Motion Controller for sure.
The controller is really cheap, so it’s a good point to start your journey with Motion Controllers.
Maybe it’s not the most precise device in the World, but it gives you a lot of fun, and your application will be awesome for sure!

If you want to read more about algorithms implemented in Leap Motion and about some internals, let me know!

Leave a Reply