July 26, 2020

[Note] Leap Motion on Ubuntu 20.04

Installation note for Leap Motion on Ubutnu 20.04.

Leap Motion

I think I got this almost 10 years ago.  It's a great device and inexpensive, but unfortunately, it didn't get too popular.  It supports Windows, Mac, Linux.  Windows with the latest SDK, for Linux, only the old version of SDK works.  It still works well.  Just like early speech recognition era, it's easier/faster to use mouse.  As with Siri, Google Voice, Alexa, motion capture technology will be used widely some day.

It can be purchased at https://www.adafruit.com/product/2106 for $89.

Installing on Ubuntu

Not straight forward - but still works.  I just finished installing it but didn't try with Java/Python SDK yet.

It works on Ubuntu 20.04, except LeapControlPanel.  Not a big deal.  Seems like upto Ubutnu 15, it worked fine, but after Ubutnu changed a few things, it doesn't any more and Leap Motion never updated SDK for Linux.

(Above is someone else's video.)

Simplified Steps

This section, just steps to install -- no output. Just follow the steps.  For detailed output see further down:

(1) Install required pacakge
$ sudo apt-get install libgl1-mesa-glx

(2) Download V2 for Linux, https://developer.leapmotion.com/setup/desktop
uncompress the downloaded file, 
$ tar zxf Leap_Motion_SDK_Linux_2.3.1.tgz

Install the deb
$ sudo dpkg -i Leap-2.3.1+31549-x64.deb 

(3) Fix Service
$ sudo vi /lib/systemd/system/leapd.service

Then add this:
Description=LeapMotion Daemon



(4) Make a symoblic link, and start service,
$ sudo ln -s /lib/systemd/system/leapd.service /etc/systemd/system/leapd.service
$ sudo systemctl daemon-reload
$ sudo service leapd start

For Python SDK: 


Executable apps are:
  • Playground - demo program
  • Visualizer - test program
  • Recalibrate - to calibrate Leap device, but after running this, it actually messed up the calibration.  Run Visualizer and Playground first to see if it works fine.  If it works fine, then no need to run this.  If your calibration gets messed up, just kill leapd and restart it.
  • LeapControlPanel - does not work properly.  It runs but not visible.

Only one hand is shown as I had to press keys to take the screenshot.


You can skip this.

* V2 SDK, https://developer.leapmotion.com/sdk/v2

"The V2 software may be used to build with our standard tracking on OSX or Linux, or with tool tracking or touchscreen-style gestures. However, many of the development assets associated with V2 are outdated, and the software is no longer supported. We strongly recommend using the more recent software versions."

* If installed w/o the required package, will get this error,

$ sudo dpkg -i Leap-2.3.1+31549-x64.deb

Selecting previously unselected package leap.
(Reading database ... 397385 files and directories currently installed.)
Preparing to unpack Leap-2.3.1+31549-x64.deb ...
Unpacking leap (2.3.1+31549) ...
dpkg: dependency problems prevent configuration of leap:
 leap depends on libgl1-mesa-glx (>= 7.7.1) | libgl1-mesa-glx-lts-precise (>= 7.7.1) | libgl1-mesa-glx-lts-quantal (>= 7.7.1) | libgl1-mesa-glx-lts-raring (>= 7.7.1) | libgl1-mesa-glx-lts-saucy (>= 7.7.1) | libgl1-mesa-glx-lts-trusty (>= 7.7.1) | libgl1-mesa-glx-lts-utopic (>= 7.7.1) | libgl1-mesa-glx-lts-vivid (>= 7.7.1); however:
  Package libgl1-mesa-glx-lts-precise is not installed.
  Package libgl1-mesa-glx-lts-quantal is not installed.
  Package libgl1-mesa-glx-lts-raring is not installed.
  Package libgl1-mesa-glx-lts-saucy is not installed.
  Package libgl1-mesa-glx-lts-trusty is not installed.
  Package libgl1-mesa-glx-lts-utopic is not installed.
  Package libgl1-mesa-glx-lts-vivid is not installed.

dpkg: error processing package leap (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:

libgl1-mesa-glx-lts-* The '*' is just Ubuntu version names, and the latest Ubuntu version that has libgl1-mesa-glx-lts package is "vivid" which is 15.04.
For Ubuntu versions, see https://en.wikipedia.org/wiki/Ubuntu_version_history

* Find libgl package for 20.04 (focal)

$ apt-cache search libgl shows:
(partial list)
libgl-dev - Vendor neutral GL dispatch library -- GL development files
libgl1 - Vendor neutral GL dispatch library -- legacy GL support
libgl1-mesa-dev - transitional dummy package
libgl1-mesa-dri - free implementation of the OpenGL API -- DRI modules
libgl1-mesa-glx - transitional dummy package
libglapi-mesa - free implementation of the GL API -- shared library
libglx-mesa0 - free implementation of the OpenGL API -- GLX vendor library
libglx0 - Vendor neutral GL dispatch library -- GLX support


libgl1-mesa-glx is 'transitional dummy package'.  Install this will fix the problem.  See:

$ sudo apt-get install libgl1-mesa-glx
[sudo] password for kkim:
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 10 not upgraded.
1 not fully installed or removed.
Need to get 5,532 B of archives.
After this operation, 78.8 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libgl1-mesa-glx amd64 20.0.8-0ubuntu1~20.04.1 [5,532
Fetched 5,532 B in 5s (1,065 B/s)         
Selecting previously unselected package libgl1-mesa-glx:amd64.
(Reading database ... 397498 files and directories currently installed.)
Preparing to unpack .../libgl1-mesa-glx_20.0.8-0ubuntu1~20.04.1_amd64.deb ...
Unpacking libgl1-mesa-glx:amd64 (20.0.8-0ubuntu1~20.04.1) ...
Setting up libgl1-mesa-glx:amd64 (20.0.8-0ubuntu1~20.04.1) ...
Setting up leap (2.3.1+31549) ...
Leap Motion installed under /usr/bin and /usr/sbin
To start the Leap Motion daemon, run:
  sudo leapd
This does not appear to be an Debian or Ubuntu-compatible distro
If you would like Leap Motion to run as a service, it is up to you
to configure systemd or /etc/init.d appropriately.
Open the Leap Motion GUI with:
See /usr/share/Leap/README.linux for more information.

What files are installed:

$ dpkg-query -L leap
/usr/bin/Playground_Data/Resources/unity default resources

Other S/W



nevyn said...

Thanks for this!! I wasn't sure how to resolve the libgl1-mesa-glx dependency issue on my own, and I had no idea how to find the samples without the control panel, so I really appreciate you posting this.

K. said...

Good to hear this helped you!

Unknown said...

thx man, u saved me 200 years of time.. finding the errors... also if u have any tips or tricks or smting i could use, i am duin my Bachelor Degree on Leap Motion so i would appreciate that

thx, Béla

K. said...

You're welcome and good luck!