Code Monkey home page Code Monkey logo

ofxleapmotion2's Introduction

ofxLeapMotion2

ofxLeapMotion2 is an OpenFrameworks addon for the second version of the LeapMotion SDK supporting skeleton tracking (beta 2.1). It is tested on Mac OSX, and should support Linux and Windows as well.

It is based on Theo Watson's original ofxLeapMotion addon.

Installation

git clone git://github.com/genekogan/ofxLeapMotion2.git

  • The addon should sit in openFrameworks/addons/ofxLeapMotion2/.

Running the Example Project

OSX

Xcode4: Open the Xcode project, select the "leapMotionExample Debug" scheme, and hit "Run".

How to Create a New ofxLeapMotion Project

To develop your own project based on ofxLeapMotion, simply copy the example project and rename it. You probably want to put it in your apps folder, for example, after copying:

openFrameworks/addons/ofxLeapMotion2/example_leap/ => openFrameworks/apps/myApps/example_leap/

Then after renaming:

openFrameworks/apps/myApps/myLeapProject/

Mac (Xcode):

Rename the project in Xcode (do not rename the .xcodeproj file in Finder!): Slow double click the project name and rename (Xcode4)

Linux ( command line )

You can simply navigate to the project folder and use make Debug, make Release or make and then execute with ./bin/example . If you have exported the OF_ROOT path you can also use make RunDebug or make RunRelease or make run ( othewise you will get an error on execution as it won't find the path of the linked .so )

Adding ofxLeapMotion to an Existing Project

Mac (Xcode):

In the Xcode project browser:

  • add the ofxLeapMotion2 sources to the project:

    • create a new group "ofxLeapMotion2"
    • drag these directories from ofxLeapMotion into this new group: ofxLeapMotion2/src & ofxLeapMotion2/libs
  • IMPORTANT!

  • On OS X, you must have this in the Run Script Build Phase of your Xcode project. where the first path ../../../addons/ofxLeapMotion2/ is the path to the ofxLeapMotion addon.

cp -f ../../../addons/ofxLeapMotion2/libs/lib/osx/libLeap.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/libLeap.dylib"; install_name_tool -change ./libLeap.dylib @executable_path/libLeap.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME";

If you don't have this you'll see an error in the console: dyld: Library not loaded: @loader_path/libLeap.dylib

Linux ( command line )

Simply add ofxLeapMotion2 to the addons.make file of your project. Remember that make RunDebug or make RunRelease or make run won't work if you don't have exported the OF_ROOT path. Executing with ./bin/yourappname will always work.

Developing ofxLeapMotion

Feel free to log bug reports and issues to the ofxLeapMotion Github page: https://github.com/genekogan/ofxLeapMotion2/issues

ofxleapmotion2's People

Contributors

edap avatar genekogan avatar hamoid avatar mikechambers avatar niccologranieri avatar npisanti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ofxleapmotion2's Issues

Issues adding Leap to existing project.

Hello, I am able to run the example leap project perfectly. However, when trying run the Leap project I get a significant amount of errors. I feel like I'm follow all of the installation instructions correctly. This is my Run Script:

cp -f ../../../addons/ofxLeapMotion2/libs/lib/osx/libLeap.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/libLeap.dylib"; install_name_tool -change ./libLeap.dylib @executable_path/libLeap.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME";

cp -f ../../../libs/fmodex/lib/osx/libfmodex.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/libfmodex.dylib"; install_name_tool -change ./libfmodex.dylib @executable_path/libfmodex.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME";

Also, the only other thing I thing could be an issue is that my project actually sits in the following directory:

OFROOT/addons/projectName

Using camera images

I don't have time to make a nice API, but I could implement a getImage() function so I'll post it here with some tips:

    void getImage(ofImage& retImage, int index) {
        Frame frame = ourController->frame();

        ImageList images = frame.images();
        if(index >= 0 && index < images.count()) {
            Image image = images[index];

            const unsigned char* image_buffer = image.data();

            //Draw the raw image data as a greyscale bitmap
            ofLogError() << image.width();
            retImage.setFromPixels(image_buffer, image.width(), image.height(), OF_IMAGE_GRAYSCALE);
        }
    }

This should be implemented in onImages() listener instead. Also,

        ourController->setPolicy(Leap::Controller::POLICY_IMAGES);

has to be set to get images, and most importantly, Allow Images has to be enabled in the Leap Motion Control Panel.

dyld: Library not loaded

I had an issue running the example XCode project, due to the dyld: Library not loaded problem.

I noticed after a while this comment on the ofApp.cpp file:

/* Note on OS X, you must have this in the Run Script Build Phase of your project.
where the first path ../../../addons/ofxLeapMotion2/ is the path to the ofxLeapMotion addon.

cp -f ../../../addons/ofxLeapMotion2/libs/lib/osx/libLeap.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/libLeap.dylib"; install_name_tool -change ./libLeap.dylib @executable_path/libLeap.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME";

If you don't have this you'll see an error in the console: dyld: Library not loaded: @loader_path/libLeap.dylib
*/

My question is, speaking of an XCode project, why is this comment there? Why isn't the line directly implemented in Run Script Build Phase?

If you let me, I could file a Pull Request, and solve the issue!

Optimization for Head-mounted Display

I am trying to get ofxLeapMotion2 to work with Oculus RIft. The optimization is implemented in the Leap library. I added the below function to set the relevant policy flag:

void optimizeForHeadMountedDisplay() {
    if (ourController) {
        ourController->setPolicyFlags(Leap::Controller::POLICY_OPTIMIZE_HMD);
        cout << ourController->policyFlags() << endl;
    }
}

The policy flag indeed gets set but the behavior doesn't change (i.e. Leap still continues function in desktop mode).

Any ideas as to what might be causing this?

Usage of ofxLeapMotion2 in Linux

hi!
first of all, thanks for providing this update for LM2. I-ve been trying to use this library through its example in a Qt project, and seems like there's some problems. What I did was to create an oF project in the project creator for qt, and then import this project into qt. That's it! haven't modified the code or manipulated or such... first I wanted to see it working as natural as possible..
and when I try to compile it, I get these errors:

/OF/libs/openFrameworks/utils/ofConstants.h:400: error: expected unqualified-id before numeric constant
#define PI 3.14159265358979323846
^

and

/OF/libs/openFrameworks/utils/ofConstants.h:400: error: expected โ€˜)โ€™ before numeric constant
#define PI 3.14159265358979323846
^

and some similar others...

would you have an idea if they have a collision or conflict with the LeapMotionMath library or something? because I think this is where the problem is, but not sure yet... or what would you think the problem is?

Thank you, any help will be appreciated!

Windows support

To use the addon with Windows, add only leap.lib to Linker->Input->Additional Dependencies, and copy leap.dll to the bin directory. I tested with VS2012.

Gesture Support

I'm using your addon in my project and I noticed there are quite a few stubs for gesture support. Since I need gestures for my project I'm going to be implementing some gesture functionality and I was going to submit a pull request when I'm done. Do you have any input on how I go about doing this?

My current plan of action is to add ofEvents to ofxLeapMotion and have updateGestures call ofNotifyEvent on each respective event (onSwipeUp onSwipeDown, etc).

To make listeners easy to implement I was going to outline a small class, ofxLeapGestureListener, which can be inherited by a user's ofApp class. ofxLeapGestureListener will provide stub methods (onSwipeUp onSwipeDown, etc) that do nothing for each action. Since the methods are not virtual, the user only needs to reimplement the event handler methods (in their ofApp class) for the gestures they care about. This is similar to how onKeyPressed, onMouseEvent, etc. are all currently handled.

To make attaching listeners easy I was going to add a method:

setupGestures(ofxLeapGestureListener * listener)

which calls ofAddListener for each event handler implemented in ofxLeapGestureListener and then calls the actual setupGestures() method.

Implemented this way, there would only be one line added (in addition to overriding any "onGestureEvent" methods) to the user's ofApp.cpp:

leapController.setupGestures(this);

Any thoughts on this?

example fails to build on linux

Hi there,
I have the leap sdk 2.1.5 on linux installed and tried to build your example. First I encountered an error:
https://gist.github.com/nylki/d7547061d2a5a1fa144e#file-errore-compiling-ofxleapmotion2-example-1

I figured I might update libs included in ofxLeapMotion with the most recent ones from the Leap SDK 2.1.5, now I get some other error instead:
https://gist.github.com/nylki/d7547061d2a5a1fa144e#file-errore-compiling-ofxleapmotion2-example-2

I would love to build the the example on Linux, would be glad if you can help me!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.