System Architecture

The Leap Motion software runs as a service (on Windows) or daemon (on Mac and Linux). The software connects to the Leap Motion Controller device over the USB bus. Leap-enabled applications access the Leap Motion service to receive motion tracking data. The Leap Motion SDK provides two varieties of API for getting the Leap Motion data: a native interface and a WebSocket interface. These APIs enable you to create Leap-enabled applications in several programming languages including JavaScript running in a browser environment.

Application Programming Interfaces

The Leap Motion SDK provides two varieties of API to get tracking data from the Leap Motion service: a native interface and a WebSocket interface. The native interface is a dynamic library that you can use to create new, Leap-enabled applications. The WebSocket interface and JavaScript client library allow you to create Leap-enabled web applications.

Native Application Interface

The native application interface is provided through a dynamically loaded library. This library connects to the Leap Motion service and provides tracking data to your application. You can link to the library directly in C++ and Objective-C applications, or through one of the language bindings provided for Java, C#, and Python.

https://di4564baj7skl.cloudfront.net/documentation/images/Arch_OS_Level_Diagram.png

Leap-enabled applications

  1. The Leap Motion service receives data from the Leap Motion Controller over the USB bus. It processes that information and sends it to running Leap-enabled applications. By default, the service only sends tracking data to the foreground application. However, applications can request that they receive data in the background (a request that can be denied by the user).
  2. The Leap Motion application runs separately from the service and allows the computer user to configure their Leap Motion installation. The Leap Motion application is a Control Panel applet on Windows and a Menu Bar application on Mac OS X.
  3. The foreground Leap-enabled application receives motion tracking data from the service. A Leap-enabled application can connect to the Leap Motion service using the Leap Motion native library. Your application can link against the Leap Motion native library either directly (C++ and Objective-C) or through one of the available language wrapper libraries (Java, C#, and Python).
  4. When a Leap-enabled application loses the operating system focus, the Leap Motion service stops sending data to it. Applications intended to work in the background can request permission to receive data even when in the background. When in the background, the configuration settings are determined by the foreground application.

WebSocket Interface

The Leap Motion service runs a WebSocket server on the localhost domain at port 6437. The WebSocket interface provides tracking data in the form of JSON messages. A JavaScript client library is available that consumes the JSON messages and presents the tracking data as regular JavaScript objects.

https://di4564baj7skl.cloudfront.net/documentation/images/Arch_WebSocket_Diagram.png

Leap-enabled web applications

  1. The Leap Motion service provides a WebSocket server listening on http://127.0.0.1:6437.
  2. The Leap Motion control panel allows end users to enable or disble the WebSocket server.
  3. The server sends tracking data in the form of JSON messages. An application can send configuration messages back to the server.
  4. The leap.js client JavaScript library should be used in web applications. The library establishes the connection to the server and consumes the JSON messages. The API presented by the JavaScript library is similar in philosophy and structure to the native API.

This interface is intended primarily for web applications, but any application that can establish a WebSocket connection can use it. The server conforms to RFC6455.