LeapMotion在Java环境中的配置——Myeclipse

20 篇文章 0 订阅
1 篇文章 0 订阅

环境配置出现困难时,能在官网找到文件的情况下尽量借助官网文件进行配置。
以下为LeapMotion在Java中环境配置说明的网址,其中也有Myeclipse中配置的说明
https://developer-archive.leapmotion.com/documentation/java/devguide/Project_Setup.html

**

Java SDK的获得

**
在配置之前需要现获得Java SDK文件。
未在官网找到,具体获得可参考文章:https://blog.csdn.net/ddaas122/article/details/88927490

**

环境配置

**
下面对官网内容进行翻译和说明:

In the Eclipse IDE, you add the LeapJava.jar file to a project as an external Jar and then set the path to the appropriate native Leap Motion libraries as a property of the Jar file.
在Eclipse IDE中,将LeapJava.jar文件作为外部Jar添加到项目中,然后将路径设置为相应的本机Leap Motion库作为Jar文件的属性。

1、Select New > Java Project from the Eclipse File menu.
1、从Eclipse File菜单中选择New> Java Project。

2、Assign a name to the project on the Create Java Project page and set other properties as desired. (The Leap Motion SDK supports Java 6 and 7.)
2、在Create Java Project页面上为项目指定名称,并根据需要设置其他属性。(Leap Motion SDK支持Java 6和7.)

3、Click Next to advance to the Java Settings page.
3、单击“ Next”以进入“Java设置”页面。

4、Select the Libraries tab.
4、选择“ Libraries”选项。

5、Click the Add External Jars… button.
5、单击Add External Jars …按钮。

6、Navigate to the LeapJava.jar file.
6、导航到LeapJava.jar文件。

7、Click Open to add LeapJava.jar to the project.
7、单击“ Open”将LeapJava.jar添加到项目中。

8、Next, click the small triangle in front of the LeapJava.jar entry in the library list to reveal the library properties.
8、接下来,单击库列表中LeapJava.jar条目前面的小三角形以显示库属性。

9、Select the Native library location item.
9、选择“Native library location”选项。

10、Click the Edit button.
10、单击“ Edit”按钮。

11、Navigate to the folder containing the Leap Motion native libraries.
11、导航到包含Leap Motion本机库的文件夹。

On Windows, be sure to select the folder containing the correct libraries for your target architecture. If you are targeting a 32-bit JVM, use the Leap Motion libraries in the x86 folder of the SDK. If you are targeting a 64-bit JVM, use the libraries in the x64 folder. On Mac, each Leap Motion library file supports both architectures.
在Windows上,请务必选择包含目标体系结构的正确库的文件夹。如果你的目标是32位JVM,请使用SDK的x86文件夹中的Leap Motion库。如果你的目标是64位JVM,请使用x64文件夹中的库。在Mac上,每个Leap Motion库文件都支持这两种体系结构。

12、Click Ok to set the path.
12、单击“ OK”以设置路径。

Note: you can also add the Leap Motion libraries to an existing project from the Project Properties dialog.
注意:你还可以从“项目属性”对话框中将Leap Motion库添加到现有项目。

**

测试程序

**
将输出识别到的手和手指的数量

package Test;

import java.io.IOException;

import com.leapmotion.leap.Controller;
import com.leapmotion.leap.Frame;
import com.leapmotion.leap.Listener;

public class Hello {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
				Controller controller = new Controller();
				SampleListener listener = new SampleListener();
				controller.addListener(listener);
				//System.out.println("hello!");
				 System.out.println("Press Enter to quit...");
			        try{
			            System.in.read();
			        } catch (IOException e) {
			            e.printStackTrace();
			        }
			        
			     // Remove the sample listener when done
			        controller.removeListener(listener);
	}
}

class SampleListener extends Listener {

	public void onConnect(Controller controller) {
			System.out.println("Connected");
	}
	
	 public void onFrame(Controller controller) {
		     Frame frame = controller.frame();

		     System.out.println("Frame id: " + frame.id()
		     				   + ", timestamp: " + frame.timestamp()
		                       + ", hands: " + frame.hands().count()
		                       +",angle"+frame.hand(0).rotationAngle(frame) +""
		                       + ", fingers: " + frame.fingers().count());
	 }
}

输出结果:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值