Leap Motion Development Essentials
()
About this ebook
Related to Leap Motion Development Essentials
Related ebooks
Instant PhoneGap Social App Development Rating: 0 out of 5 stars0 ratingsInstant Android Fragmentation Management How-to Rating: 0 out of 5 stars0 ratingsHTML5 for Flash Developers Rating: 5 out of 5 stars5/5Herding Cats and Coders: Software Development for Non-Techies Rating: 5 out of 5 stars5/5Practical Bot Development: Designing and Building Bots with Node.js and Microsoft Bot Framework Rating: 0 out of 5 stars0 ratingsKnockoutJS Blueprints Rating: 0 out of 5 stars0 ratingsBuilding Slack Bots Rating: 0 out of 5 stars0 ratingsDeep Learning with Azure: Building and Deploying Artificial Intelligence Solutions on the Microsoft AI Platform Rating: 0 out of 5 stars0 ratingsJavaScript Security Rating: 4 out of 5 stars4/5Hands-on MuleSoft Anypoint platform Volume 1 Rating: 5 out of 5 stars5/5PhoneGap for Enterprise Rating: 0 out of 5 stars0 ratingsLearning NServiceBus Sagas Rating: 0 out of 5 stars0 ratingsINSTANT JQuery Flot Visual Data Analysis Rating: 0 out of 5 stars0 ratingsInstant Apache ActiveMQ Messaging Application Development How-to Rating: 0 out of 5 stars0 ratingsGetting Started with Meteor.js JavaScript Framework - Second Edition Rating: 0 out of 5 stars0 ratingsLearning D3.js Mapping Rating: 0 out of 5 stars0 ratingsSignalR – Real-time Application Development - Second Edition Rating: 0 out of 5 stars0 ratingsDesigning Microservices using Django: Structuring, Deploying and Managing the Microservices Architecture with Django Rating: 0 out of 5 stars0 ratingsInstant HTML5 Geolocation How-To Rating: 0 out of 5 stars0 ratingsBuilding Blockchain Projects Rating: 2 out of 5 stars2/5Building Web Applications with Flask Rating: 0 out of 5 stars0 ratingsBuilding UIs with Wijmo Rating: 0 out of 5 stars0 ratingsLearning Windows Server Containers Rating: 0 out of 5 stars0 ratingsKinect in Motion – Audio and Visual Tracking by Example Rating: 0 out of 5 stars0 ratingsBuilding Bots with Microsoft Bot Framework Rating: 0 out of 5 stars0 ratingsMastering JavaScript Design Patterns - Second Edition Rating: 5 out of 5 stars5/5Learn C++ for Game Development Rating: 0 out of 5 stars0 ratingsLearning HTML5 by Creating Fun Games Rating: 4 out of 5 stars4/5Machine Learning with Spark - Second Edition Rating: 0 out of 5 stars0 ratings
Programming For You
Java for Beginners: A Crash Course to Learn Java Programming in 1 Week Rating: 5 out of 5 stars5/5Game Development with Unreal Engine 5: Learn the Basics of Game Development in Unreal Engine 5 (English Edition) Rating: 0 out of 5 stars0 ratingsExcel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5C# Programming from Zero to Proficiency (Beginner): C# from Zero to Proficiency, #2 Rating: 0 out of 5 stars0 ratingsPython Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Learn JavaScript in 24 Hours Rating: 3 out of 5 stars3/5Python QuickStart Guide: The Simplified Beginner's Guide to Python Programming Using Hands-On Projects and Real-World Applications Rating: 0 out of 5 stars0 ratingsPYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Python Machine Learning By Example Rating: 4 out of 5 stars4/5Problem Solving in C and Python: Programming Exercises and Solutions, Part 1 Rating: 5 out of 5 stars5/5Python Data Structures and Algorithms Rating: 5 out of 5 stars5/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5The Unofficial Guide to Open Broadcaster Software: OBS: The World's Most Popular Free Live-Streaming Application Rating: 0 out of 5 stars0 ratingsPython GUI Programming Cookbook - Second Edition Rating: 5 out of 5 stars5/5Learn SQL in 24 Hours Rating: 5 out of 5 stars5/5
Reviews for Leap Motion Development Essentials
0 ratings0 reviews
Book preview
Leap Motion Development Essentials - Mischa Spiegelmock
Table of Contents
Leap Motion Development Essentials
Credits
About the Author
About the Reviewers
www.packtpub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Leap Motion SDK – A Quick Start
An overview of the SDK
Quick start
Major SDK components
Controller
Config
Screen
Math
Frame
Hand
Pointable
Finger positioning
An example of cursor control
A gesture-triggered action
Summary
2. Real Talk – Real Time
A simple gesture recognizer
Using the MIDI output
Blocking and latency
Multiprocessing with threads
Refactoring for multithreading
The producer-consumer race condition
Summary
3. Actual Gestures
Computer input
Natural gestures
Receiving gestures
WindowFlinger – a high-level gesture application
Window management abstraction
Window docking
Driver implementation – Mac OS X
Accessibility API
flinger::MacDriver
Summary
4. Leap and the Web
HTML5 and Leap
WebSocket
The Leap Motion service
LeapJS
JavaScript visualization
Summary
5. HTML5 Antics in 3D
Cross-platform graphics party
WebGL
Three.js + LeapJS – the awesomesauce
Animating rotation
Summary
Index
Leap Motion Development Essentials
Leap Motion Development Essentials
Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2013
Production Reference: 1211013
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84969-772-9
www.packtpub.com
Cover Image by Suresh Mogre (<suresh.mogre.99@gmail.com>)
Credits
Author
Mischa Spiegelmock
Reviewers
Shaun Walker
Carlos Zinato
Acquisition Editors
Erol Staveley
Rebecca Youe
Commissioning Editor
Mohammed Fahad
Technical Editors
Vrinda Nitesh Bhosale
Pratik More
Amit Ramadas
Project Coordinator
Suraj Bist
Proofreader
Bernadette Watkins
Indexer
Hemangini Bari
Production Coordinator
Manu Joseph
Cover Work
Manu Joseph
About the Author
Mischa Spiegelmock is an accomplished software engineer from the San Francisco Bay Area. Slightly infamous from light-hearted technical pranks from his youth, he is now a respectable CTO at a healthcare software startup. His passions are architecting elegant and useful programs and sharing his insights into software design with others in a straightforward and entertaining fashion.
This book would not exist without the extremely passionate people at Leap Motion, whose vision and heroic efforts to improve the interactions between humans and computers should be commended. Special mention to Elizabeth Ruscitto for taking the time to provide me with informative answers to my queries. I would also like to thank Hep Svadja Hepic Photography, for the amazing pictures.
About the Reviewers
Shaun Walker is a software and web developer from Tasmania, Australia. He enjoys tinkering with electronics, listening to music, playing computer games, and working on small projects that generally never get finished.
Shaun has a Bachelor's degree in Computing, majoring in Human Interface Technology, part of the HITLab, an International collaboration effort between a few universities around the world. His areas of focus during his studies were in augmented reality, virtual reality, and gesture-based interactions.
With a history in corporate IT support, working on network integration, software and web development, his main employment is with a Brisbane-based medical start-up.
Ramblings by Shaun can be found at his blog at http://theshaun.com or on Twitter @theshaun.
Carlos Zinato, aged 25, is from São Paulo, Brazil. Currently, he's living in Miami Beach, FL, developing mobile apps and games, playing bass guitar, and getting to know people and places.
Working with tools such as Objective-C, Leap Motion, Titanium, and Unity3D, Carlos makes mobile apps and games and this is what he loves to do.
Carlos is currently aiming to keep making awesome apps and games with skilled friends and teams. He not only cares about the money but, more importantly, about the knowledge. Carlos wants to keep working with brilliant people that enhance his job, his life, and his pocket.
www.packtpub.com
Support files, eBooks, discount offers and more
You might want to visit www.packtpub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packtpub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.packtpub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
www.packtpub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
Fully searchable across every book published by Packt
Copy and paste, print and bookmark content
On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.packtpub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Preface
Once in a great while, a revolutionary and exciting new way of interacting with technology comes along. Leap Motion makes natural gesture-based interfaces a reality, and gives software developers access to a large and powerful set of features and capabilities. This guide is for software engineers who wish to get an overview of the Leap Software Development Kit modules, types and interfaces in C++ along with some guidelines for getting the most out of your Leap device and creating usable, gestural software interfaces.
What this book covers
Chapter 1, Leap Motion SDK – A Quick Start, explores how to begin using the Leap C++ SDK right away, with a sample mouse control program. It covers how to receive frame updates and read finger position data.
Chapter 2, Real Talk – Real Time, guides you through writing a multithreaded MIDI controller, which uses a blocking OS call without sacrificing responsiveness.
Chapter 3, Actual Gestures, covers a high-level discussion of gesture interfaces and a look at the available Leap SDK recognizers. It also covers creating an interface to manipulate Windows OS.
Chapter 4, Leap and the Web, teaches you how to create Leap-enabled web pages, using JavaScript with the LeapJS library, with no additional installation or configuration.
Chapter 5, HTML5 Antics in 3D, combines LeapJS, WebGL, and Three.js together to manipulate objects in 3D space in a web page using Leap Motion.
What you need for this book
You will need a working knowledge of basic C++ and a compiler. Additional demonstration operating system-specific code is provided for Mac OS X APIs, but neither OS X nor familiarity with it is a requirement. An understanding of basic geometry and concepts such as vectors is useful for spatial manipulations.
Who this book is for
This book is for developers with an interest in using the Leap Motion input device with their software. This book gives a broad overview of most of the available functionality in the Leap SDK, which can be transferred to any of the supported language interfaces, as the data types and routines are nearly identical.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: We can include other contexts through the use of the include directive.
A block of code is set as follows:
if (frame.hands().empty()) return;
const Leap::Hand firstHand = frame.hands()[0];
const Leap::FingerList fingers = firstHand.fingers();
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
namespace leapmidi {
typedef double
midi_control_value_raw
;
typedef unsigned short
midi_control_value;
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes, for example, appear in the text like this: Prepare to be astounded when you point at the middle of your screen and the transfixing message, You are pointing at (0.519522, 0.483496, 0), is revealed
.
Note
Warnings or important notes appear in a box like this.
Tip
Tips and