O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mastering Leap Motion

Book Description

Design robust and responsive Leap Motion applications for real-world use

In Detail

Leap Motion technology offers a truly innovative way of interacting with software. Traditionally, computing has always involved the use of a keyboard, a mouse, or a controller. Leap Motion gives developers a new solution to creating a radically new user experience, in a way that is both comprehensive and disruptive in the most exciting sense of the term. From typing to robotic hands and virtual harps, Leap Motion makes human and computer interaction so much more immersive.

Beginning with a quick step-by-step guide to get you set up and an overview of how the Leap Motion API works to consolidate your knowledge, the book then looks closely at writing a 2D painting application and explores how to create a 3D application. Featuring diagrams, screenshots, and code examples to guide you as you master Leap Motion, this book will keep you in touch with the future of technology.

What You Will Learn

  • Get to grips with the various functions and tools provided for developers by the Leap Motion API
  • Understand how Leap Motion detects and handles various gestures and movements made by users, including ergonomics and fatigue
  • Create a simple 2D painting application using only Java and the Leap Motion API
  • Design and create a 3D application using the Unity 3D toolkit
  • Troubleshoot, debug, and optimize Leap Motion applications to improve their responsiveness
  • Explore the future of Leap Motion technology and where it might be used tomorrow

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Mastering Leap Motion
    1. Table of Contents
    2. Mastering Leap Motion
    3. Credits
    4. Foreword
    5. About the Author
    6. Acknowledgments
    7. About the Reviewers
    8. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    9. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Errata
        2. Piracy
        3. Questions
    10. 1. Introduction to the World of Leap Motion
      1. Setting up the Leap Motion device
      2. Installing the Leap Motion Developers' SDK
      3. Installing the Java JDK
      4. Setting up your IDE
      5. Structure of the Leap Motion Application Programming Interface (API)
        1. The Vector class
        2. The Finger class
        3. The Hand class
        4. The Frame class
        5. The Controller class
        6. The Listener class
      6. Creating a simple framework program within the Eclipse IDE
        1. Setting up the project
        2. Let's write some code!
        3. Trying it out
      7. Looking forward – the Skeletal Tracking API
        1. Different fingers? Not a problem
        2. Handedness is no longer an issue
        3. Having confidence in tracking data
        4. Pinching and grabbing are now much easier
        5. A new API class – Bones
        6. That's it!
      8. Summary
    11. 2. What the Leap Sees – Dealing with Fingers, Hands, Tools, and Gestures
      1. Handling hands and fingers
        1. The Leap's field of view
        2. The InteractionBox class
          1. How the interaction box works
          2. Why would you ever want to use something like the interaction box?
      2. Detecting gestures and tools
        1. Detecting and using tools
      3. Gestures
        1. Detecting gestures
      4. Some (albeit minor) limitations to keep in mind
        1. Upside-down hands can be a problem!
        2. Needing too many hands is a bad thing
        3. Differentiating fingers can be fun!
        4. Lack of support for custom gestures
      5. Summary
    12. 3. What the User Sees – User Experience, Ergonomics, and Fatigue
      1. When to use the Leap (and more importantly, when not to)
      2. The Leap Motion user experience guidelines
      3. Ergonomics and user fatigue
        1. Ergonomics
        2. User fatigue
      4. A case study – the Artemis Quadrotor Simulator
        1. Play testing and why you should do it
        2. Providing as much visual feedback as possible
        3. That's it – for now!
      5. Summary
    13. 4. Creating a 2D Painting Application
      1. Laying out the framework for Leapaint
        1. LeapButton.java
        2. LeapaintListener.java
        3. Leapaint.java
      2. Creating the graphical frontend
        1. Making a responsive button – the LeapButton class
          1. Getting our bounds
          2. Visually responding to the user
        2. Making a graphical user interface
          1. Constructing a constructor
        3. Saving images
      3. Interpreting Leap data to render on the graphical frontend
      4. Testing it out
      5. Improving the application
      6. Summary
    14. 5. Creating a 3D Application – a Crash Course in Unity 3D
      1. A brief introduction to Unity
      2. Installing and setting up Unity 3D
      3. Common jargon found in Unity
        1. Scenes
        2. GameObjects
        3. Scripts
      4. Creating a project
      5. Setting the scene
      6. Summary
    15. 6. Creating a 3D Application – Integrating the Leap Motion Device with a 3D Toolkit
      1. Setting up the scene to receive Leap Motion input
      2. A quick summary – the fundamentals of Unity scripts
        1. Attaching a script to a GameObject
      3. Laying out a framework of scripts
      4. Rendering hands
        1. LeapListener.cs
        2. HandRenderer.cs
        3. Preparing the scene for hand rendering
        4. Testing out the Hand Renderer
      5. Rendering buttons and detecting button presses
        1. BaseSingleton – a custom singleton pattern
        2. Colorscheme – a utility class to keep track of colors
        3. Core – the main class, if Unity had main classes
        4. TouchPointer – let's draw some cursors on the screen
        5. TouchableButton – surely, the name is self-explanatory
        6. TitleMenu – a simple main menu
        7. Putting it all together
      6. Summary
    16. 7. Creating a 3D Application – Controlling a Flying Entity
      1. Creating the flying entity
        1. Adding the PlayerArrow and Rigidbody components
      2. Retrieving user input with the HandController class
      3. Interpreting user input with the Player class
      4. Putting everything together and testing it
        1. Improving the application
      5. Summary
    17. 8. Troubleshooting, Debugging, and Optimization
      1. Making sure your Leap is connected
        1. The Diagnostic Visualizer
      2. Keeping the Leap Motion SDK updated
      3. Cutting back on Leap Motion API calls
      4. Handling the NoSuchMethod and NoClassDefFound errors in Java
      5. Custom calibration of the Leap Motion Controller
      6. Summary
    18. 9. Going beyond the Leap Motion Controller
      1. What you've learned so far
      2. The Leap Motion Controller standing next to other emerging technologies
        1. Microsoft's Kinect
        2. Oculus VR's Oculus Rift
      3. Reliability and safety concerns with the Leap in industrial settings
      4. Going beyond – ideas to control hardware and robots with the Leap Motion Controller
        1. Arduino
        2. A few things you'll need
          1. Setting up the environment
          2. Setting up the project
          3. Writing the Java side of things
          4. Writing the Arduino side of things
          5. Deploying and testing the application
        3. Ideas for Leap-driven applications – simulators and robots
      5. FIRST Robotics Competition Robots
        1. The FIRST Robotics Competition
        2. Controlling an FRC robot with the Leap Motion Controller
      6. Making a robot of your own!
      7. Summary
    19. Index