Ventuz版本6.4
Leapmotion版本3.2.0(可以从官网https://developer.leapmotion.com/releases/?category=orion上下载)
1、解压Leapmotion压缩包,先安装驱动
2、进入LeapSDK文件夹,在lib文件夹下找到LeapCSharp.NET3.5.dll文件,通过gacutil.exe将LeapCSharp.NET3.5.dll添加到程序集缓存中去。(gacutil.exe文件正常是找不到的,需要默认安装Visual Studio后,在C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin路径下能找到)
3、
a.右键电脑右下方开始按钮,点击运行按钮,在运行中输入cmd,点击确认
b.在命令窗口输入cd C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin,键盘按下Enter键;然后输入gacutil -i "LeapCSharp.NET3.5.dll所在的路径"
出现Assembly successfully added to the cache,表示添加成功。
重点提示!!!!!!:我的Leapmotion2.0硬件不支持Leapmotion SDK 3.0.0之前的SDK,请确认你的硬件是1.0还是2.0.
还有就是如果你下载下来的SDK中没有找到LeapCSharp.NET3.5.dll文件,请下载和我一样的版本。
4、在LeapSDK\lib下,选择X86或者X62(根据你的系统选择)下的Leap.dll和LeapC.dll复制到你的Ventuz安装根目录下,就可以了。
5、下面是Ventuz下的C#脚本
using System; using Ventuz.Kernel; using System.Threading; using Leap; using System.EnterpriseServices.Internal; public class Script : ScriptBase, System.IDisposable { //Leap Motion Listener and controller SampleListener listener = new SampleListener (); Controller controller = new Controller(); // This member is used by the Validate() method to indicate // whether the Generate() method should return true or false // during its next execution. private bool changed; // This Method is called if the component is loaded/created. public Script() { controller.Connect += listener.OnServiceConnect; controller.Device += listener.OnConnect; controller.FrameReady += listener.OnFrame; } // This Method is called if the component is unloaded/disposed public virtual void Dispose() { controller.Connect -= listener.OnServiceConnect; controller.Device -= listener.OnConnect; controller.FrameReady -= listener.OnFrame; controller.Dispose(); } // This Method is called if an input property has changed its value public override void Validate() { // Remember: set changed to true if any of the output // properties has been changed, see Generate() } // This Method is called every time before a frame is rendered. // Return value: if true, Ventuz will notify all nodes bound to this // script node that one of the script's outputs has a // new value and they therefore need to validate. For // performance reasons, only return true if output // values really have been changed. public override bool Generate() { if(listener.IsChanged) { CircleCCW(); }else{ } return false; } } //Sample Listener Class public class SampleListener { public bool IsChanged; public void OnServiceConnect(object sender, ConnectionEventArgs args) { Console.WriteLine("Service Connected"); } public void OnConnect(object sender, DeviceEventArgs args) { Console.WriteLine("Connected"); } public void OnFrame(object sender, FrameEventArgs args) { // Get the most recent frame and report some basic information Frame frame = args.frame; if(frame.Hands.Count > 0){ IsChanged = true; } else{ IsChanged = false; } } }测试是可以用的,自己调这个花了三天时间,希望给刚接触的人一点帮助。若有疑问邮箱联系1281551269@qq.com.