# Is LeapMotion Module updated?

**URL:** <https://discourse.slicer.org/t/is-leapmotion-module-updated/13073>\
**Category:** Support\
**Created:** [August 18, 2020, 1:57pm UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073 "2020-08-18T13:57:50Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [August 18, 2020, 1:57pm UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/1 "2020-08-18T13:57:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 19, 2020, 5:20am UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/2 "2020-08-19T05:20:22Z")

</div>

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](https://discourse.slicer.org/t/slicerleapmotioncontrol-in-slicer-4-11-0/6770/15)), 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.

---

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [January 11, 2021, 9:29am UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/3 "2021-01-11T09:29:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 11, 2021, 7:34pm UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/4 "2021-01-11T19:34:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [January 11, 2021, 8:59pm UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/5 "2021-01-11T20:59:36Z")

</div>

How to enable it?  
PLUS\_USE\_LEAPMOTION in Cmake config?.. Maybe

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 11, 2021, 9:10pm UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/6 "2021-01-11T21:10:01Z")

</div>

Exactly. Follow the build instructions here: [GitHub - PlusToolkit/PlusBuild: CMake scripts for building Plus library, applications, and all required dependencies](https://github.com/PlusToolkit/PlusBuild)

---

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [January 14, 2021, 10:24pm UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/7 "2021-01-14T22:24:12Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 15, 2021, 12:10am UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/8 "2021-01-15T00:10:31Z")

</div>

@adamrankin Is the latest Plus supposed to support LeapMotion?

---

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [January 15, 2021, 1:41am UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/9 "2021-01-15T01:41:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 15, 2021, 1:58am UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/10 "2021-01-15T01:58:21Z")

</div>

> [@timeanddoctor](#):
>
> why not use a python 2.7 to broadcast the leapmotion data into slicer?

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.

---

<div class="post-metadata">

**Author:** ![adamrankin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/adamrankin/32/155_2.png) [@adamrankin](https://discourse.slicer.org/u/adamrankin)\
**Post date:** [January 15, 2021, 2:28am UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/11 "2021-01-15T02:28:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [January 15, 2021, 2:41pm UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/12 "2021-01-15T14:41:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [January 16, 2021, 3:39am UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/13 "2021-01-16T03:39:03Z")

</div>

Link to the video:

[![](https://img.youtube.com/vi/OXN7-yPlEHM/hqdefault.jpg "LeapMotion OpenIGTLinkIF") ](https://www.youtube.com/watch?v=OXN7-yPlEHM)

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

Thanks…

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 16, 2021, 5:15am UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/14 "2021-01-16T05:15:02Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [January 16, 2021, 10:30am UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/15 "2021-01-16T10:30:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 16, 2021, 2:38pm UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/16 "2021-01-16T14:38:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [January 23, 2021, 8:42am UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/17 "2021-01-23T08:42:10Z")

</div>

> [@adamrankin](#):
>
> es, the leap is supported by Plus. Our students were using it last fall.

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!

---

<div class="post-metadata">

**Author:** ![adamrankin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/adamrankin/32/155_2.png) [@adamrankin](https://discourse.slicer.org/u/adamrankin)\
**Post date:** [January 23, 2021, 1:12pm UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/18 "2021-01-23T13:12:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 23, 2021, 3:10pm UTC](https://discourse.slicer.org/t/is-leapmotion-module-updated/13073/19 "2021-01-23T15:10:19Z")

</div>

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