Remote access to leap motion data

 • 

总结:迷一样的 leap motion

服务器端设置

开启允许远程连接设置

参考:https://developer.leapmotion.com

其中关于websockets_allow_remote

Key string websockets_allow_remote
Value type boolean
Default value false
Purpose Allows non-localhost clients to connect

就是说,要去把默认关掉的这个参数改为开启,于是要去改 leap motion 的 config 文件,config.json的文件路径:

Linux:  
~/.Leap Motion/config.json
Mac:
~/Library/Application Support/Leap Motion/config.json
Windows: 
%AppData%\Leap Motion\config.json

改完后记得重启 leap motion service 才能生效,重启方法:Mac / Windows

测试是否开启成功

leap motion 安装的时候自带了一个名为 SDK Samples 的文件夹,我已经忘了 Mac 版是不是默认安装到这个目录了,不过还是写下,至少便于自己以后访问这个文件夹:

/Developer/LeapSDK/samples

修改JSONViewer.html第28行,从

function init() {
    // Create and open the socket
    ws = new WebSocket("ws://localhost:6437/v6.json");

改为

function init() {
    // Create and open the socket
    ws = new WebSocket("ws://你的目前的内网 IP 地址:6437/v6.json");

然后测试是否能够从内网 IP 访问,测试时请确保连接上 leap motion,control panel 里打开了 tracking 功能,没有开启任何 proxy 软件,若有数据刷新,则成功。
此部分参考:https://community.leapmotion.com

客户端设置

var controller = new Leap.Controller({host:'xxx.xxx.xxx.xxx', port:6437});
controller.setBackground(true);

以上是 javascript SDK 的 Controller constructor,可以直接定从哪个地址读取数据,但是 Unity/C# 版本目前貌似没有这个功能。