Hello!
Friends of the Leap Motion are that they leave. Yesterday they have released a new version of the SDK and the truth is that it brings quite a few interesting things. Among them there are 2 that are especially useful: Pitch and Grab. In the following video you can see how the action of Pitch gives a value between 0 and 1 when they come together the fingers of the hand. And Grab also gives a value between 0 and 1 for the action of seizing.
Another interesting fact is that we now have 2 properties that allow us to identify if the hand that is on the sensor is the left or right hand. The names are the most original IsLeftHand and IsRightHand.
As much as I do the code is not very complicated. In this case the controller of the Leap, analyzes in the event OnFrame() if there is any hand on it (line 15). Then on the first detected hand a series of events are released with the pitch, Grab and identification of left & right hand value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Threading.Tasks; | |
| using Leap; | |
| namespace ElBruno.LeapV2NewFeatures | |
| { | |
| public class MotionListener : Listener | |
| { | |
| public event Action<bool, bool> OnLeftOrRightHand; | |
| public event Action<float, float> OnPitchAndGrab; | |
| public override void OnFrame(Controller controller) | |
| { | |
| var frame = controller.Frame(); | |
| if (frame.Hands.IsEmpty) return; | |
| var hand = frame.Hands[0]; | |
| Task.Factory.StartNew(() => OnLeftOrRightHand(hand.IsLeft, hand.IsRight)); | |
| Task.Factory.StartNew(() => OnPitchAndGrab(hand.PinchStrength, hand.GrabStrength)); | |
| } | |
| } | |
| } |
The WPF app subscribes to these events and shows the value of them as seen in the video.
Saludos @ La Finca
El Bruno
Leave a comment