1. ASUS X450J
2. Windows 8.1
3. VS 2012
4. Leap Motion SDK 1.0.9+8391
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//----
// 1. Copy LeapC#.NET.4.0, Leap.DLL, LeapC#.DLL into project folder
// 2. Add the first one as reference and add two others as existed items.
//----
using Leap;
namespace ConsoleEx1
{
class Program
{
static void Main(string[] args)
{
SampleListener listener = new SampleListener();
Controller controller = new Controller();
controller.AddListener(listener);
// Keep this process running until Enter is pressed
Console.WriteLine("Press Enter to quit...");
Console.ReadLine();
controller.RemoveListener(listener);
controller.Dispose();
}
}
class SampleListener : Listener
{
private Object thisLock = new Object();
private void SafeWriteLine(String line)
{
lock (thisLock)
{
Console.WriteLine(line);
}
}
public override void OnConnect(Controller controller)
{
SafeWriteLine("Connected");
}
//public override void OnFrame(Controller controller)
//{
// SafeWriteLine("Frame available");
//}
public override void OnFrame(Controller controller)
{
Frame frame = controller.Frame();
SafeWriteLine("Frame id: " + frame.Id
+ ", timestamp: " + frame.Timestamp
+ ", hands: " + frame.Hands.Count
+ ", fingers: " + frame.Fingers.Count
+ ", tools: " + frame.Tools.Count
+ ", gestures: " + frame.Gestures().Count);
}
}
}
沒有留言:
張貼留言