Is LeapMotion Module updated?

Hi people,

Slicer version: Slicer 4.11.0-2020-07-04 Win

I´m trying to control scene view with LeapMotion device and I have some trouble.
I follow installation steps from GitHub proyect (download drivers and put them inside module folder)

Slicer don´t show me “Gesture control / LeapMotion control module” and Python interactor send this error message:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\appar\AppData\Local\NA-MIC\Slicer 4.11.0-2020-07-04\lib\Python\Lib\imp.py", line 170, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 618, in _exec
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "E:/Dicom Files 2/SlicerLeapMotionControl-master/Demo1/Leap.py", line 28, in <module>
    LeapPython = swig_import_helper()
  File "E:/Dicom Files 2/SlicerLeapMotionControl-master/Demo1/Leap.py", line 24, in swig_import_helper
    _mod = imp.load_module('LeapPython', fp, pathname, description)
  File "C:\Users\appar\AppData\Local\NA-MIC\Slicer 4.11.0-2020-07-04\lib\Python\Lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\appar\AppData\Local\NA-MIC\Slicer 4.11.0-2020-07-04\lib\Python\Lib\imp.py", line 343, in load_dynamic
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 684, in _load
  File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: No se puede encontrar el módulo especificado.
Traceback (most recent call last):
  File "E:/Dicom Files 2/SlicerLeapMotionControl-master/Demo1/SlicerLeapModule.py", line 20, in __init__
    logic = SlicerLeapModuleLogic()
  File "E:/Dicom Files 2/SlicerLeapMotionControl-master/Demo1/SlicerLeapModule.py", line 164, in __init__
    self.LeapController = Leap.Controller()
AttributeError: module 'Leap' has no attribute 'Controller'

Thanks on advance.

Unfortunately, Leap has official Python API only for Python2 (this is what is bundled with SlicerLeapMotion extension).

Slicer-4.11 uses Python3, so you need to build build and wrap the LeapMotion API yourself. It is not very simple (see some attempts described here), but should be possible, since Slicer uses standard Python 3.6.7, so if you can make or find anything that works with this Python version then it will work in Slicer, too.

Hi again @lassoan ,
Searching for a way to manage Slicer scene with LeapMotion, I´ve found a Plus Toolkit config file example. It doesn´t recognice Leap controler but should be easier to fix than python wrapper for Slicer LeapMotion Module. Do you think about this way?

I agree that using Plus to connect to LeapMotion should be a good approach, especially if you already use Plus to connect to other imaging or tracking devices. Probably all you need to do is to build Plus with LeapMotion enabled.

1 Like

How to enable it?
PLUS_USE_LEAPMOTION in Cmake config?.. Maybe

Exactly. Follow the build instructions here: GitHub - PlusToolkit/PlusBuild: CMake scripts for building Plus library, applications, and all required dependencies

1 Like

I´ve some trouble building Plus with LeapMotion. Stable 2.8 branch doesn´t have Leap option so I´ve been trying with master branch:
Config:
VS 2017 Comm
Qt 5.7
Leap SDK

Both x86 / x64 version throw me compiling errors in VS related with x64 o Win32 issues.

Is there any item combination that should work? Do I need PLUSBUILD_INSTALL_ITK option? Any other option is not compatible with x64? What EXTERNAL_VTK_VERSION is the right one?

Thanks!

@adamrankin Is the latest Plus supposed to support LeapMotion?

why not use a python 2.7 to broadcast the leapmotion data into slicer? And if you just went have a communicate during surgery you can use the old stable slicer to browse the DICOM$volume Renderiing.

I guess the issue with Slicer-4.10, Python2, and LeapMotion’s Python interface is that they all 3 are obsolete and unsupported. Any time you spend with them is wasted effort because even if you manage to make something work, it is very likely that you will need to abandon what you implemented and switch to current software/API versions sooner than later.

1 Like

@lassoan Yes, the leap is supported by Plus. Our students were using it last fall.

2 Likes

Ok. It´s working.
Config:
Win10
VS 2017 Comm
LeapMotion SDK (LeapDeveloperKit_4.1.0+52211_win)
QT 5.7 (qt-opensource-windows-x86-msvc2015_64-5.7.0)

I´ve all finger transform working. I´ll send you a video these next days.

1 Like

Link to the video:

About gesture… These upgrade should be implemented in Plus device code or throw a manage module of transforms?

Thanks…

2 Likes

This looks great! To send gestures, you need to update the LeapMotion class in Plus toolkit. For example, you could add gesture information in custom fields (contents of custom fields appear as MRML node attributes in Slicer).

Does any other PlusLib Device that work in this way as example for this task? Or any documentation to follow?

SonixVideo device adds custom fields. There should be a few more, you can search for customfield in the source code for more examples.

1 Like

Although the scene works correctly, models movement has significant delay with hands movement. Is there any parameter in Plus config file I can change to fix it?

Thanks!

Sadly the performance slow down happens in Slicer and is unavoidable without programming changes.

One workaround you can try is to send less transforms from Plus. Can you get away with just one fingers’ joints? Can you limit it to one hand? Maybe just the finger tip joints?

The slowdown comes from the quantity of transmitted joints.

1 Like

We will do some performance optimization after Slicer’s switch to VTK9 is completed (see Rendering performance needs improvement · Issue #5398 · Slicer/Slicer · GitHub).

2 Likes