SlicerLeapMotionControl in Slicer 4.11.0

#1

Operating system:windows10
Slicer version:4.11.0
Expected behavior: **SlicerLeapMotionControl**can work
Actual behavior:SlicerLeapMotionControl cannot work

I add the src directory to the additional module paths,but there are some errors in python.
What can I do to make the SlicerLeapMotionControl work in Slicer4.11? It can work in Slicer4.8.

(Jean Christophe Fillion Robin) #2

Thanks for reporting the problem.

Since Slicer was recently updated to use with Python 3 (see [1] for more details), extensions and more general any example of code also need to be updated to support python 3 and it seems the SlicerLeapMotionControl scripts still need to be updated to support it.

[1] Updating slicer to work with python 3

(Jean Christophe Fillion Robin) #3

For reference, migration guide explaining how to update code to work with Python 3 is available at https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/MigrationGuide#Slicer_5.0:_Python2_to_Python3

I will update the code following the migration guide, it would be great if you could test the changes once this is done.

(Jean Christophe Fillion Robin) #4

Here is a PR that should fix the issue reported in your initial screenshot: https://github.com/lassoan/SlicerLeapMotionControl/pull/1

That said, there are most likely other problem to address. Could you try the updated code available in the Pull request linked above and report the other errors ?

#5

Wow,it’s a pleasure to do the test work.:joy:
Is it after midnight in America or Canada? :rofl: You replied so soon at this time.
I will try your suggestions in the future hours.

#6

Em,I switch to the code you just push but there are still errors.

(Andras Lasso) #7

Probably you need to download the LeapMotion Python SDK, and replace SDK files in the extension’s folder with their Python3 version.

(Jean Christophe Fillion Robin) #8

It also looks like you are still using the old version of the file. Line is expected to be different.
See https://github.com/lassoan/SlicerLeapMotionControl/pull/1/commits/8034a17836ee23c42e867e576a3d3d5e42c97436

#9

I modify the SlicerLeapModule.py according to your code.It now has different errors.

(Jean Christophe Fillion Robin) #10

The next step would be to obtain the leap motion SDK for python 3.x.

Reading https://developer.leapmotion.com/releases, it seems they have been removed from the latest SDK (Leap Motion Orion 4.0.0):

Removed Leap.dll, all associated language bindings (LeapPython, LeapJava, Objective-C) and samples Leap Motion Orion 4.0.0

Now, reading the “Setting up a project” section found in the v3.2 of the documentation, we can find information about the python bindings:

The LeapPython library included in the Leap Motion SDK supports only Python 2.7. However, the SDK also includes the SWIG interface file used to generate the LeapPython source code, so advanced users can generate and compile their own version of LeapPython. For instructions, refer to Generating a Python 3.3.0 Wrapper with SWIG 2.0.9 in our support knowledge base.

If you download the v3.2 of the SDK and try to follow instruction from https://support.leapmotion.com/hc/en-us/articles/223784048 , you should be able to address the remaining issues.

Also look like there are readily available code to make the python 3 binding for linux … see https://github.com/BlackLight/leap-sdk-python3 but i couldn’t find a similar project.

Note that it may exist, i just didn’t spend too much time searching …

Enable Leap motion and 3D slicer to work together
#11

I compile and generate LeapPython.dll(x86) file successfully by following this


But there are still errors.

And when I build LeapPython.dll(x64) with Leap.lib(x64),link error occur.

(Andras Lasso) #12

You can probably fix the link errors by using the 64-bit LeapMotion library files.

#13

Hi ,@jcfr @lassoan i did the same thing that @JaceYang did , i build LeapPython.dll with Leap.lib(x64), it can successfully generate LeapPython.dll, so i change it to leapPython.pyd and put it into the demo1 folder to replace the old one,and then add it to 3D Slicer, but those errors have not changed comparing to the unmodified source code( original source code) and they are the same errors that Jace Yang has got.