May 022013
 
 May 2, 2013  Posted by at 8:10 am C# & F#, Motion Tracking, Uncategorized  Add comments
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 DotnetConf last 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

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 Fritz for taking the time to discuss code with me, where would we be without great colleagues and friends :) Also a big thanks to Carey, Scott and Michael :) – you know you rock ;)

26 comments on “Developing for Leap Motion in C# Tutorial (video, slides and code)

  1. Sandeep on said:

    Thanks for the excellent tutorials Iris, i have a question “when the MainWindow is not in focus, leap doesnt try to read the fingers, how can we change that to read always? “

  2. Henry Pollet on said:

    Thanks for thème vidéo ! I Will receivethe leap Motion and of this week and used your code

    Regards

    • Iris Classon on said:

      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/

  3. Shintaro Sasaki on said:

    I just want to tell you THANK YOU for the tutorial. This is awesome. You are AWESOME.

  4. Mario Esposito on said:

    love it! I want to tray that with Sensoria Gaming/Fitness http://08milluz.wordpress.com/2013/08/07/sensoria-gdk/

  5. Mukesh Rawat on said:

    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.

  6. jayesh jain on said:

    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..

  7. 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

  8. Prachi Gujar on said:

    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)

    • Iris Classon on said:

      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.

  9. Mina Metias on said:

    Thank you, for the brief – but however extremely efficient- tutorial :)

  10. 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:UsersL31006DesktopLeap-Motion-masterLeap_WPFUtilCustomListener.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:UsersL31006DesktopLeap-Motion-masterLeap_WPFViewModelMainViewModel.cs 58 38 Leap_WPF

    Do help if you can.. Thanks!

    • Iris Classon on said:

      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!

  11. student on said:

    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′

    • Iris Classon on said:

      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.

  12. Hey, thanks a lot for your tutorial…. but i have a problem… how i know which finger is doing a tap???

    • Iris Classon on said:

      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.

  13. Mykel K on said:

    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!

    • Michel K on said:

      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!

      • Iris Classon on said:

        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.

    • Iris Classon on said:

      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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

HTML tags are not allowed.

What is 9 + 4 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)