Reader small image

You're reading from  Leap Motion Development Essentials

Product typeBook
Published inOct 2013
PublisherPackt
ISBN-139781849697729
Edition1st Edition
Right arrow
Author (1)
Mischa Spiegelmock
Mischa Spiegelmock
author image
Mischa Spiegelmock

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.
Read more about Mischa Spiegelmock

Right arrow

A simple gesture recognizer


One of the handy methods we can call on a Leap::Hand is sphereRadius(), which returns the size of an imaginary ball filling up a hand. The more outstretched your fingers are the larger the radius, and a more clenched fist will produce smaller values.

What does our ball gesture recognizer class look like? Feast your eyes on this:

typedef std::shared_ptr<BallGesture> BallGesturePtr;
   
void BallGesture::recognizedControls(const Leap::Controller &controller, std::vector<ControlPtr> &controls) {
    Leap::Frame frame = controller.frame();
    if (frame.hands().empty())
        return;

If no hands are found in the current frame, there's not much else for us to do here. However, if the user is waving some appendages around, we can do our thing.

    for (int i = 0; i < frame.hands().count(); i++) {
        if (i > 1) break;

If one or two hands are detected in the frame, we might be able to do something useful. We can get extra fancy if we return...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Leap Motion Development Essentials
Published in: Oct 2013Publisher: PacktISBN-13: 9781849697729

Author (1)

author image
Mischa Spiegelmock

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.
Read more about Mischa Spiegelmock