ofxLeapMotion2: addon for new beta of Leap SDK with skeleton tracking

Hi all,

I’ve created an addon wrapping the newest Leap SDK (beta v. 2.0.1) which supports hand skeleton tracking. The newest SDK is much improved from the last one as it identifies fingers by type (index, middle, ring, etc) instead of keeping them unordered, and it does a much better job at detecting fingers despite occlusion.

The addon is basically a copy of Theo’s original ofxLeapMotion except that the newest SDK has been swapped in and you can now call fingers by their individual type, as well as get the individual joints in each finger.

I’ve tested this working on OSX 10.7, I expect it should work on more recent OSX. If anyone can test it on Windows/Linux, that would be useful as well.

Here is the link: https://github.com/genekogan/ofxLeapMotion2

Hope this is helpful.

best,
gene

1 Like

I am trying to give this a go in VS but for the life of me cannot figure out the right linking I need to do to avoid:

Error	39	error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall Leap::Controller::removeListener(class Leap::Listener &)" (__imp_?removeListener@Controller@Leap@@QAE_NAAVListener@2@@Z) referenced in function "public: void __thiscall ofxLeapMotion::close(void)" (?close@ofxLeapMotion@@QAEXXZ)	C:\Users\coleman\Desktop\OF_Dev\of_v0.8.1_vs_release\apps\myApps\myLeap\ofApp.obj	myLeap

Which I can only assume it means it isnt finding the library?

Nevermind, After 5 hours of linking and such, I finally tracked down everything and got it working in VS2012 - here is it for those that want to give it a go, many thanks to Gene for the hard work on this! I am teaching a workshop in Wuhan China tomorrow with it!
Chris
LeapMotion2Example.zip (1.7 MB)

Hay there, with ubuntu 14.04 64bit i get the following error:

In file included from ../../../libs/openFrameworks/ofMain.h:5:0,
                 from src/main.cpp:1:
../../../libs/openFrameworks/utils/ofConstants.h:359:19: error: expected unqualified-id before numeric constant
  #define PI       3.14159265358979323846
                   ^
../../../addons/ofxLeapMotion2/libs/include/LeapMath.h:24:20: note: in expansion of macro ‘PI’
 static const float PI          = 3.1415926536f;
                    ^
../../../libs/openFrameworks/utils/ofConstants.h:359:19: error: expected unqualified-id before numeric constant
  #define PI       3.14159265358979323846
                   ^
../../../libs/openFrameworks/utils/ofConstants.h:379:22: note: in expansion of macro ‘PI’
  #define DEG_TO_RAD (PI/180.0)
                      ^
../../../addons/ofxLeapMotion2/libs/include/LeapMath.h:30:20: note: in expansion of macro ‘DEG_TO_RAD’
 static const float DEG_TO_RAD  = 0.0174532925f;
                    ^
../../../libs/openFrameworks/utils/ofConstants.h:359:19: error: expected ‘)’ before numeric constant
  #define PI       3.14159265358979323846
                   ^
../../../libs/openFrameworks/utils/ofConstants.h:379:22: note: in expansion of macro ‘PI’
  #define DEG_TO_RAD (PI/180.0)
                      ^
../../../addons/ofxLeapMotion2/libs/include/LeapMath.h:30:20: note: in expansion of macro ‘DEG_TO_RAD’
 static const float DEG_TO_RAD  = 0.0174532925f;
                    ^
../../../libs/openFrameworks/utils/ofConstants.h:383:22: error: expected unqualified-id before numeric constant
  #define RAD_TO_DEG (180.0/PI)
                      ^
../../../addons/ofxLeapMotion2/libs/include/LeapMath.h:36:20: note: in expansion of macro ‘RAD_TO_DEG’
 static const float RAD_TO_DEG  = 57.295779513f;
                    ^
../../../libs/openFrameworks/utils/ofConstants.h:383:22: error: expected ‘)’ before numeric constant
  #define RAD_TO_DEG (180.0/PI)
                      ^
../../../addons/ofxLeapMotion2/libs/include/LeapMath.h:36:20: note: in expansion of macro ‘RAD_TO_DEG’
 static const float RAD_TO_DEG  = 57.295779513f;
                    ^
In file included from src/ofApp.h:4:0,
                 from src/main.cpp:2:
../../../addons/ofxLeapMotion2/src/ofxLeapMotion2.h: In member function ‘std::vector<ofxLeapMotionSimpleHand> ofxLeapMotion::getSimpleHands()’:
../../../addons/ofxLeapMotion2/src/ofxLeapMotion2.h:286:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0; i < leapHands.size(); i++){
                                           ^
make[1]: *** [obj/linux64/Release/src/main.o] Fehler 1
make[1]: Verlasse Verzeichnis '/home/lukas/OpenFreamworks/addons/ofxLeapMotion2/example_leap'
make: *** [Release] Fehler 2

Someone has an idea what could be the problem?

Edit: i found a solution in the forum (had do #ifndef PI)

obj/linux64/Release/src/main.o:(.rodata._ZTIN4Leap8HandListE[_ZTIN4Leap8HandListE]+0x10): Nicht definierter Verweis auf `typeinfo for Leap::Interface'
obj/linux64/Release/src/main.o:(.rodata._ZTIN4Leap4HandE[_ZTIN4Leap4HandE]+0x10): Nicht definierter Verweis auf `typeinfo for Leap::Interface'
obj/linux64/Release/src/main.o:(.rodata._ZTIN4Leap5FrameE[_ZTIN4Leap5FrameE]+0x10): Nicht definierter Verweis auf `typeinfo for Leap::Interface'

It seems like it can’t find the library
Thanks in advance,
Lukas

edit:
Found the solution:
i simly had to edit the makefiles PROJECT_LDFLAGS
In my specific case:

PROJECT_LDFLAGS=-Wl,-rpath=./libs
PROJECT_LDFLAGS+=./libs/libLeap.so

cause i placed the lib file in {$PROJECT}/libs/

thanks @digitalColeman for the windows example! i’ve linked to it in the readme.

Hey there, I have a similiar problem, enclosing the static defines doesnt work anymore, as the defines changed a slightly. Could you give me a hint? :slight_smile:

Hello Gene,

Thank you very much for the wonderful addon:)))
I am building one of my school projects on it with oF0.8.4 but I have experienced some problem and hopefully you or some gurus here could help me out:)))

I have been trying to draw an ofImage but the colour has been distorted as negative colours. Moreover, when I was trying to draw an image from the webcam, there were some glitches appeared…

It would be very nice if you could give me some advice :)))

Thanks a lot and have a lovely weekend!

Cheers,
Karen

hi karen,
this doesn’t sound like a problem with ofxLeapMotion2. could you post a code example? try putting ofSetColor(255) before you draw your ofImage. does that solve it?
gene

Thanks Gene! ofSetColor(255); solved it :stuck_out_tongue:
Merci beaucoup! x

Hi, I still get that error “error LNK2019: unresolved external symbol…” using your vs2012 example

I compiled it in x86 platform, how did you resolve that problem??

Thanks :slight_smile:

sorry for the late response…
i’m not the one who added the vs project file, and i don’t use VS so i’m not sure precisely how to fix it but it looks like you are getting a linker error which means the static library’s not getting linked to your project file. make sure the .dll inside ofxLeapMotion/libs/ gets linked to your project before you build it.

Hey,

I am on linux here, using OF on qt, I added the addon to the folder, changed the .qbs file to build my project with the addon.
added #include “ofxLeapMotion2.h” and the build was fine.

then I added ofxLeapMotion leap; on the .h file.

when building I got the errors on the print

not sure if I am missing some step

Thanks!!

same problem over here

Well, I’ve used the addon in Linux, in a Qt openframeworks project and it works. The only problem is when I move the hand really quick, it crashes… the qt project and therefore the running program. What I get is a segmentation fault and a operating system crash
does this has to be with the addon?