Developing for Leap Motion in C# Tutorial (video, slides and code)
Developing for leap Motion in C# Tutorial (video, slides and code)
I did a presentation on Leap Motion at the virtual conference DotnetConflast week, and I’ve spent the weekend cleaning up the code a little bit an putting together a simple video tutorial as it seems quite a few were interested and wanted some help to get started, and a step by step guide on how to develop for Leap Motion.
As soon as I find some time I will put together a detailed article on the Leap Motion- but I reckon you will get very far,- i not further with the video tutorial, the code, the conference session and the slides.
Here is everything you need - apart from the SDK and the device- to get started developing for Leap Motion in C#!
The slides
Developing for Leap Motion from Iris Classon
Slides on Leap Motion development can be found on my Slideshare account
Video tutorial with quick demo
I walk you through the what is it, how does it work (not as detailed as in the conference session), and then the code - step by step. The code is a WPF application using MVVM designpattern (not to 100%) and is a modified version of the application I made for the conference session. The Leap Motion application in C# and XAML can be found in my GitHhub repo Leap Motion (link provided below).
Developing for Leap Motion in C# Part 1
Developing for Leap Motion in C# Part 2
The conference session:
I demonstrate the Leap with several applications, get more into details of how it works, and I show both the code for three different console applications (that actually do the same thing LOL), and a WPF application.
The conference session on Leap Motion can be watched here. Slides used are the same as above, and can be found on Slideshare.
The code
The code for the application used for the tutorial can be found here, DLL’s for Leap Motion are not included as I’m not allowed to share those. Sign up, download the SDK and add the DLL’s as described in the tutorial or the slides.
Big thank you to Jeff Fritzfor taking the time to discuss code with me, where would we be without great colleagues and friends :) Also a big thanks to Carey, Scottand Michael:) - you know you rock ;)
Comments
Do you mean that you want a program that runs in the background as a service?
I think that Sandeep wants to say : if the mainwindow is open but an other windows of an other program has the focus. Very nice job
Thanks for thème vidéo ! I Will receivethe leap Motion and of this week and used your code Regards
Sweet, and congrats! Let me know how it goes and feel free to ask questions! Here is a list of questions BTW: 16 questions on Leap Motion answered http://www.irisclasson.com/2013/07/02/stupid-question-200-216-16-questions-on-leap-motion-answered/
I just want to tell you THANK YOU for the tutorial. This is awesome. You are AWESOME.
love it! I want to tray that with Sensoria Gaming/Fitness http://08milluz.wordpress.com/2013/08/07/sensoria-gdk/
I downloaded the sample code provided by you for Leap Motion.I added the all api required to run application but it is showing error in below line: var screen = _controller.CalibratedScreens.ClosestScreenHit(fingers[0]); Error Details : ‘Leap controller could not contain a definition for ‘CalibratedScreens’ and no extension method ‘CalibratedScreens’ accepting a first argument of type ‘LeapController’ could be found (are your missing a using directive or an assembly reference?) Can you help me out ? Thanks.
used 'locatedScreens' instead of 'CalibratedScreens' and it worked nicely.
well,I am zero at c#.And unfortunately i have just got an assignment where I have to design a gesture based powerpoint presentation? Can any body guide me..i am absolute begineer at it..
Hej, I have a question about the Leap Motion Controller used as a mouse. I'm writing my bachelor thesis and I need exactly that :D. I watched your videos above and also downloaded the code. You 've said that the code in the "LeapAsMouse" Class is absolutely enough to enable this feature. Would this work the same way in C++? I'm more a java programmer than a C++/C# programmer so maybe you can help me. Många hälsningar
i am creating new assembly file .dll which i will be using in maxscript. how should i add leap.dlll and leapCsharp.dll in my assembly .dll file.. (c# code)
I haven't worked with maxscript before, but if its is an 'ordinary' .Net application then add the C# dll's and set copy to output always. If you can give me some more information I might be able to better help you! I (and a fellow dev) are publishing a course on developing for Leap Motion in C# next week, I'll email you once the course is out, there is a free trial where the course is published ( www.pluralsight.com ) :) It's a very good course that covers both a simple example, and a more complete example.
Thank you, for the brief - but however extremely efficient- tutorial :)
Hi, encountered with 2 errors and the programme can't be run.. Error 1 'Leap.HandList' does not contain a definition for 'Empty' and no extension method 'Empty' accepting a first argument of type 'Leap.HandList' could be found (are you missing a using directive or an assembly reference?) C:\Users\L31006\Desktop\Leap-Motion-master\Leap_WPF\Util\CustomListener.cs 33 29 Leap_WPF Error 2 'Leap.Controller' does not contain a definition for 'locatedScreens' and no extension method 'locatedScreens' accepting a first argument of type 'Leap.Controller' could be found (are you missing a using directive or an assembly reference?) C:\Users\L31006\Desktop\Leap-Motion-master\Leap_WPF\ViewModel\MainViewModel.cs 58 38 Leap_WPF Do help if you can.. Thanks!
No code errors but this was prompted and stop the program from running. 'The invocation of the constructor on type 'Leap_WPF.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'
Hi the tutorial was done on one of the first versions of the SDK and a lot has changed since then. I'll see if I can find some time and update this tutorial.
The tutorial is on an old version of the SDK, the screen object is now deprecated and Empty is now called IsEmpty if I remember correctly. An up to date tutorial I've made is here: http://pluralsight.com/training/courses/TableOfContents?courseName=developing-leap-motion-csharp There is a free trial if you don't have a subscription. I'll make a new tutorial for the blog soon, and ping you once its done. Feel free to contact me if I can be of any help!
Hey, thanks a lot for your tutorial.... but i have a problem... how i know which finger is doing a tap???
Thank you :) Try grabbing the Pointable, have a look at the documentation here: https://developer.leapmotion.com/documentation/Languages/CSharpandUnity/API/class_leap_1_1_screen_tap_gesture.html Leap.ScreenTapGesture Class: Properties Vector Direction [get] The direction of finger tip motion. Pointable Pointable [get] The finger performing the screen tap gesture. Vector Position [get] The position where the screen tap is registered. float Progress [get] The progess value is always 1.0 for a screen tap gesture.
yep... that class should works... thanks, i putt my hands to works...bye
Hi Iris, I downloaded and extracted the tutorial code and am getting two errors. "Leap.Controller' does not contain a definition for 'CalibrateScreens and no extension method..." lines 58 and 86... Do you have an idea of how to fix this error? As I am new to Leap Motion and want to really understand all help and advice are appreciated. Thank you!
Also I did try the suggestion from above for the locatedScreens. But I still have the same error now indicating no definition for locatedScreens. So any advice is greatly appreciated! Thanks!
AS I wrote the SDK is old and the screen methods are deprecated so the code will not run as is. The tutorial was made while the SDK was in beta and I haven't had the time to record new ones. I will do that as soon as I can, hopefully over Christmas. The course here: http://pluralsight.com/training/courses/TableOfContents?courseName=developing-leap-motion-csharp is up to date (by me and John). There is a free trial for Pluralsight. Give that a go, and I'll ping you as soon as I get this tutorial updated.
AS I wrote the SDK is old and the screen methods are deprecated so the code will not run as is. The tutorial was made while the SDK was in beta and I haven't had the time to record new ones. I will do that as soon as I can, hopefully over Christmas. The course here: http://pluralsight.com/training/courses/TableOfContents?courseName=developing-leap-motion-csharp is up to date (by me and John). There is a free trial for Pluralsight. Give that a go, and I'll ping you as soon as I get this tutorial updated.
Hi Iris I'm new on Leap Motion Development, I was try to use a sample from https://developer-archive.leapmotion.com/documentation/v2/csharp/devguide/Project_Setup.html#windows-forms, but when I try to run it, the creation of a controller (Controller controller = new Controller();) shows the error message: "The type initializer for Leap.LeapPINVOKE threw an exception" Please, help me
Last modified on 2013-05-02