Getting and installing LeapMotionP5

While the recent post about using LeapMotionP5 discussed using the library it did not explain how to install it.

The installation for use with Processing is the same as for all user-contributed Processing libraries.

There are instructions for this here.

Basically, you locate your sketchbook folder (which the default location to where you save your Processing sketches) and within that folder there should be a “libraries” folder. That “libraries” folder holds all 3rd-party libraries.

The source code for LeapMotionP5 is up on Github and you can grab that source and manually install the appropriate files into your Processing libraries folder. This would be tedious. The repo includes a “downloads” folder that contains a zip file of the ready-to-install library (currently “LeapMotionP5-0.2.0.zip”).

Github does not make it easy to just download this file. You can get it by checking out the repo, but to make life easier I am also hosting the zipped distrubtable version here on Leap Hacking.

Over on the Downloads page you’ll be able to get the latest release of LeapMotionP5.

You can then download this file, move or copy to over to your Processing libraries folder, and extract it there. It should create a LeapMotionP5 folder containing all the files you need.


Read more ...

LeapMotionP5 examples part 1

The LeapMotionP5 library started off as a simple wrapper for the Leap Motion Java library that is part of the Leap Motion software developer kit (SDK).

It worked, and worked well. The first version of the Pointer Location example was written to use that early version.

Later, LeapMotionP5 was updated to allow other ways of accessing the Leap Motion data. As the library evolved new versions of the Pointer Location were created to show usage.

This, and subsequent articles, is meant to help explain how to use the LeapMotionP5 library by way of some examples. In particular, there is are a series of simple example that takes the average of finger-top positions and renders that data on a corresponding screen location. This basic premise is presented in multiple ways to show the different ways you can use the LeapMotionP5 library.


Read more ...

LeapMotionP5 Updated

I’m still wrapping up some docs and examples for the Neurogami LeapMotionP5 library for Processing, but I have updated it to use the latest Leap Motion libraries.

There are a few other changes as well. Most notable is that the library now allows you to use it in a variety of ways. The first version was mainly a wrapper around the Leap Motion Java libraries; you would write Processing code that largely mimicked how you would write a Java program. I liked this because it is conceptually clean and makes it easy to steal ideas and examples from existing Leap Motion Java examples.

However, in some cases you (or I) may want to write a sketch that does everything in one file, with core flow handled by the `draw` method.

Or do something in-between.

The current version of LeapMotionP5 now supports this. The repo has a multiple versions of a pointer location demo to show the different ways to use the library.

I’ve been working on some longer articles to walk through each of these versions and when ready I’ll post them here.


Read more ...

The Pleasures of JRuby

On March 19, 2013 I gave a presentation at the Ruby User Group in Phoenix, AZ. I went on much longer than I really should have. The response to the talk was good, there were a lot good questions, and I showed a good number of examples. I think, though, that I may have gone over the code examples way too quickly.

There was one thing in particular that I find quite useful, and while I mentioned it (and had Vim up on the screen for about 30 seconds showing the code) I want to discus it more here. It’s a very powerful feature of JRuby, which is the main language I use for my Leap coding.

JRuby is an implementation in Java of the Ruby programming language. There are two notable virtues to this. One, it tends to be faster (modulo program start-up times that including the initialization of a JVM) than the standard C-based implementation of Ruby. Two, being written in Java you can load Java libraries and use them as if (more or less) they were Ruby libraries.

This is how I am able to use the Leap Motion Java jars in my code. It’s also how I use the Processing libraries for my UI.

That’s quite good.

But there’s yet another slick feature. In Ruby it is possible to re-open a class and add or change behavior. You can do this both for you own classes as well as the classes built-in to Ruby (or, for that matter, anyone else’s code you are using in your own program).

For example, Ruby provides an Array class. Arrays come with assorted built-in methods. Sometimes, though, you want for something that isn’t already provided.

Suppose you often are dealing with nested arrays, and want to get some kind of aggregate information, such as the total number of elements in all the arrays. There’s no built-in method that does exactly that, but here’s one way you could do it:



  def total_elements nested_ary
    nested_ary.inject(0) { | sum, ary|
      sum += ary.size
    }
  end

  a1 = %w{ a b c d}
  a2 = %w{ u v w x y }
  nested =  [a1, a2]

  total = total_elements nested 

  p total


Now whenever you need to get the total number of items in a nested array you can call that method.


Read more ...

Notes from a Leap Motion Presentation, part 3: Socket to me

This is part three of a write-up based on a recent presentation I gave showing off the Leap Motion Controller.

You can read part one here

You can read part two here


Read more ...

Notes from a Leap Motion Presentation, part 2: Playing Around

This is part two of a write-up based on a recent presentation I gave showing off the Leap Motion Controller. You can read part one here

In this part I’ll go through a JRuby program that acts as a WebSocket server to control a simple browser-based game.


Read more ...

Notes from a Leap Motion Presentation, part I: JRuby

On Wednesday, February 13, 2913, I gave a somewhat casual presentation at HeatSync Labs to show off a few things I’ve learned about the Leap Motion. This is a write-up of most of that presentation. It has some additional detail that I did not cover that night.


Read more ...