Hand Analysis Tutorial Intel RealSense SDK 2014



Similar documents
* * * Intel RealSense SDK Architecture

Introduction to the Perceptual Computing

Intel Perceptual Computing SDK My First C++ Application

HAND GESTURE BASEDOPERATINGSYSTEM CONTROL

A Method for Controlling Mouse Movement using a Real- Time Camera

Mouse Control using a Web Camera based on Colour Detection

UniFinger Engine SDK Manual (sample) Version 3.0.0

TELEPHONE BUTTONS & ICONS TOUCHSCREEN OVERVIEW

An Introduction to OSVR

IV3Dm provides global settings which can be set prior to launching the application and are available through the device settings menu.

GelAnalyzer 2010 User s manual. Contents

Amit Moran, Gila Kamhi, Artyom Popov, Raphaël Groscot Perceptual Computing - Advanced Technologies Israel

GestPoint Maestro3D. A White Paper from GestureTek The Inventor of 3D Video Gesture Control

SDK Design Guidelines

AR-media TUTORIALS OCCLUDERS. (May, 2011)

Game Programming with DXFramework

GUIDE TO POST-PROCESSING OF THE POINT CLOUD

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

The SwannCloud Mobile App

Multi-Touch Control Wheel Software Development Kit User s Guide

White Noise Help Guide for iphone, ipad, and Mac

2. About iphone ios 5 Development Essentials. 5. Joining the Apple ios Developer Program

Next Generation Natural User Interface with Kinect. Ben Lower Developer Community Manager Microsoft Corporation

Storage and Playback Getting Started Guide

Microsoft Windows PowerShell v2 For Administrators

Basler. Area Scan Cameras

Quick Start Tutorial Imperial version

Introduction to NaviGenie SDK Client API for Android

[PACKTl. Flash Development for Android Cookbook. Flash, Flex, and AIR. Joseph Labrecque. Over 90 recipes to build exciting Android applications with

GLOVE-BASED GESTURE RECOGNITION SYSTEM

User Manual PIXPRO SP360. (Smart Device Version) For KODAK PIXPRO SP360 Action Cam. Ver. 5.1

Chapter 4 Control Center

Mobility with Eye-Fi Scanning Guide

Wave 4.5. Wave ViewPoint Mobile 2.0. User Guide

Video Tracking Software User s Manual. Version 1.0

Manual Client Management Software HDR50-CMS

The Keyboard One of the first peripherals to be used with a computer and is still the primary input device for text and numbers.

Sybase Unwired Platform 2.0

The Scientific Data Mining Process

13 Managing Devices. Your computer is an assembly of many components from different manufacturers. LESSON OBJECTIVES

Affdex SDK for Windows!

MS 10978A Introduction to Azure for Developers

Quick Start Tutorial Metric version

TELEMED ONLINE DEMO GUIDE FOR SYSTEM INSTALLATION & ONLINE DEMO

This tutorial assumes that Visual3D has been installed and that a model has been created as described in Tutorial #1.

How To Draw On An Ipad With A Touch Tablet (For Free) On A Blackberry Or Ipad 2 (For A Sims) On An Easter Egg (For An Sims 2) On Blackberry 2 (Blackberry)

How To Use Titanium Studio

orrelog Ping Monitor Adapter Software Users Manual

A. OPENING POINT CLOUDS. (Notepad++ Text editor) (Cloud Compare Point cloud and mesh editor) (MeshLab Point cloud and mesh editor)

Wiley Publishing, Inc.

Professional Organization Checklist for the Computer Science Curriculum Updates. Association of Computing Machinery Computing Curricula 2008

Interactive Data Mining and Visualization

Smile IP Contact Center Autodialer server console User manual

The BSN Hardware and Software Platform: Enabling Easy Development of Body Sensor Network Applications

Master Thesis Using MS Kinect Device for Natural User Interface

ios 9 Accessibility Switch Control - The Missing User Guide Updated 09/15/15

CHAPTER 2: USING THE CAMERA WITH THE APP

VIRTUAL TRIAL ROOM USING AUGMENTED REALITY

Professor, D.Sc. (Tech.) Eugene Kovshov MSTU «STANKIN», Moscow, Russia

FUNDAMENTALS OF ROBOTICS

IceWarp to IceWarp Server Migration

MA-WA1920: Enterprise iphone and ipad Programming

UniCom Enterprise Phone (Polycom CX600) User Guide

Tutorial: Biped Character in 3D Studio Max 7, Easy Animation

Multi-Touch Ring Encoder Software Development Kit User s Guide

Dashboard Skin Tutorial. For ETS2 HTML5 Mobile Dashboard v3.0.2

Centralized Monitoring Management Platform Manual

Virtual Phone System User Guide v4.7

, SHAPE Services

CS 534: Computer Vision 3D Model-based recognition

Virtuozzo Virtualization SDK

VPAT for Apple ipad Air 2

Quick Start Guide. Microinvest Warehouse Pro Light Restaurant

Blender addons ESRI Shapefile import/export and georeferenced raster import

Ready Light on lowerright of frame bezel

understanding sensors

Trigger-to-Image Reliability (T2IR)

Tutorial on Basic Android Setup

CMS-DH CENTRAL MANAGEMENT SOFTWARE

Mobile Communicator for Mobile Devices

How To Run A Factory I/O On A Microsoft Gpu 2.5 (Sdk) On A Computer Or Microsoft Powerbook 2.3 (Powerpoint) On An Android Computer Or Macbook 2 (Powerstation) On

How to develop your own app

Lenovo Miix 2 8. User Guide. Read the safety notices and important tips in the included manuals before using your computer.

ACN CALLING PLAN FEATURES ALABAMA GEORGIA FLORIDA KENTUCKY LOUISIANA NORTH CAROLINA SOUTH CAROLINA TENNESSEE

mouse (or the option key on Macintosh) and move the mouse. You should see that you are able to zoom into and out of the scene.

Sign-up Tool User Manual

Enhanced Imaging Options for Client Profiles for Windows

PolyWorks V10 Beginner s Guide

Communicating Agents Architecture with Applications in Multimodal Human Computer Interaction

Microsoft Introduction to Azure for Developers

Virtual Mouse Using a Webcam

Test Automation Product Portfolio

Guarding Expert (Android Tablet) Mobile Client Software User Manual (V3.1)

Chapter 1. Introduction to ios Development. Objectives: Touch on the history of ios and the devices that support this operating system.

Fleet Manager Quick Guide (Non Maintenance Mode)

CTvox for Android. Version 1.5

Transcription:

Hand Analysis Tutorial Intel RealSense SDK 2014 With the Intel RealSense SDK, you have access to robust, natural human-computer interaction (HCI) algorithms such as face tracking, finger tracking, gesture recognition, voice and speech recognition, fully textured 3D scanning and enhanced depth augmented reality. With the SDK you can create Windows* desktop applications that offer innovative user experiences. This tutorial shows how to enable the hand analysis module of the SDK and enable its features, such as hand and finger tracking, robust 22-point skeletal joint tracking, and gesture recognition. The module can also display event alert notifications in your application, and a basic rendering utility is provided to view the output data. 1

Contents Overview Hand Analysis Data Gesture Tracking Hand Alert Notification Code Sample Files Creating a Session for Hand Analysis Hand Tracking Initialize the Pipeline Stream Hand Analysis data Gesture Tracking Initialize the Pipeline Stream the Gesture Analysis Data Alert Event Notifications Initialize the Pipeline Stream the Alert Notification Data Rendering the Frame Cleaning up the Pipeline Running the Code Sample To learn more Intel RealSense SDK Hand Analysis Tutorial 2

Overview The Intel RealSense SDK supports input/output modules and algorithm modules. In this tutorial, you ll see how to use one of the algorithm modules in particular the hand analysis module. To learn more about I/O modules, see the Capturing Raw Streams tutorial. The PXCHandAnalysis interface of the SDK is the representation of the hand analysis module. PXCHandAnalysis uses its class member functions to perform hand and joint tracking, gesture recognition, and alert event notifications for multiple hands in an image frame. Hand Analysis Data Applications can locate and return a hand (or multiple hands) through the PXCHandData interface. Applications must capture hand data before they can capture any other data related to a hand. The hand data is exposed to the application through the ihand interface that provides the following data: Mass Center: Image and world coordinates of the calculated hand image mass center. Extremity Points: Special tracking points such as the left most point and the right most point. Body Side: Whether it is a left or right hand. Palm Orientation: Estimation of where the hand is facing. Tracked Joints: Position and rotations of the user s hand in world and image coordinates. Normalized Joints: Posture of user s hand without changing dimensions of the hand, i.e., the distances between each joint (bone-length) are always the same. Finger Data: Degree of foldedness and the radius of a particular fingertip. Segmentation Image: Rectangle of the boundaries of only the hand in the image. Gesture Tracking Using the PXCHandData interface, you can also extract gesture information. By default, certain 3 Intel RealSense SDK Hand Analysis Tutorial

defined hand movements, also known as gesture packs, can be loaded for detection. Gesture Name Illustration Description spreadfingers The hand is open facing the camera with fingers pointing upwards. fist Fingers folded into a fist. tap Hand moving in z direction as if one is pressing a button. thumb_down The hand is closed with the thumb finger pointing down. thumb_up The hand is closed with the thumb finger pointing up. two_fingers_pinch_open The thumb finger and the index finger touch each with vertical orientation of the hand. v_sign Index and middle fingers extended in upwards direction. Hand Alert Notification This module helps notify your application of certain useful information: Hand detection and tracking: Inform the application that a hand is identified and is tracked. Hand calibration: Inform the application that hand calibration data is available. Tracking Boundaries: Inform the application when the tracked hand goes out or is about to go out of the tracking boundaries. Intel RealSense SDK Hand Analysis Tutorial 4

Code Sample Files You can use either procedural calls or event callbacks to capture hand data, and relevant code samples showing both are listed in Table 1. Using event callbacks is usually preferred when developing console applications; procedural calls are often used for GUI applications. This tutorial s code samples use procedural calls. The handanalysis_render.cpp file, provided with the code samples, contains the HandRender utility class that renders an image sample that contains hand analysis data. It is provided with this tutorial so that you do not have to create your own hand rendering algorithm. Executable files (.exe) are provided in the Debug subfolder in the code sample directory. Table 1: Hand Analysis Code Samples Code Sample Hand analysis using procedural calls Code sample file: main_hand_analysis_procedural.cpp Hand analysis using event callbacks Gesture analysis using procedural calls or events Alert notification using procedural calls or events For explanation, see: This Tutorial. Also see Hand Tracking using the SenseManager Procedural Functions section of the SDK Reference Manual. Hand Tracking using the SenseManager Callback Functions section of the SDK Reference Manual. Gesture Recognition Data section of the SDK Reference Manual. Handle Alert Notification section of the SDK Reference Manual. 5 Intel RealSense SDK Hand Analysis Tutorial

Creating a Session for Hand Analysis 1. Create a session and instance of the PXCSenseManager to add the functionality of the Intel RealSense SDK to your application. 2. Initialize an instance of the HandRender utility class so that you can render the captured image samples. //SDK provided utility class used for rendering (packaged in libpxcutils.lib) #include "handanalysis_render.h" // initialize the UtilRender instances HandRender *renderer = new HandRender(L"Procedural Hand Tracking"); // create the PXCSenseManager PXCSenseManager *psm=0; psm = PXCSenseManager::CreateInstance(); if (!psm) wprintf_s(l"unable to create the PXCSenseManager\n"); return 1; The SDK core is represented by two interfaces: PXCSession: manages all of the modules of the SDK PXCSenseManager: organizes a pipeline by starting, stopping, and pausing the operations of its various modalities. Note: Each session maintains its own pipeline that contains the I/O and algorithm modules. Intel RealSense SDK Hand Analysis Tutorial 6

Hand Tracking Initialize the Pipeline 1. Enable the Depth Stream of given size using EnableStream and PXCCapture type. 2. Enable the hand analysis using EnableHand. 3. Initialize the pipeline using Init. 4. Retrieve hand module if ready using QueryHand. 5. Retrieve the hand data using CreateOutput on the hand module. 6. Create an image instance for the color sample. Note: You must use sts of type pxcstatus for error checking. // error checking Status pxcstatus sts; // select the color stream of size 640x480 and depth stream of size 640x480 psm->enablestream(pxccapture::stream_type_depth, 640, 480); // enable hand analysis in the multimodal pipeline sts = psm->enablehand(); if (sts < PXC_STATUS_NO_ERROR) wprintf_s(l"unable to enable Hand Tracking\n"); return 2; // retrieve hand results if ready PXCHandModule* handanalyzer = psm->queryhand(); if (!psm) wprintf_s(l"unable to retrieve hand results\n"); return 2; // initialize the PXCSenseManager if(psm->init() < PXC_STATUS_NO_ERROR) return 3; PXCHandData* outputdata = handanalyzer->createoutput(); PXCImage *colorim = NULL; 7 Intel RealSense SDK Hand Analysis Tutorial

Stream Hand Analysis data 1. Acquire Frames in a loop using AcquireFrame(true): a. TRUE (aligned) to wait for color and depth samples to be ready in a given frame; else b. FALSE (unaligned). 2. In every iteration of the frame loop first Update() on the hand module to update the Hand data. 3. Create data structures of type JointData to hold the data per frame. 4. Use QueryHandData to populate ihand, a hand with appropriate access order type. 5. On a given instance of ihand you can QueryTrackedJoint with JointType to extract individual joints. // stream data while (psm->acquireframe(true)>=pxc_status_no_error) outputdata->update(); // create data structs PXCHandData::JointData nodes[num_hands][pxchanddata::number_of_joints]=; // iterate through hands pxcuid handid; pxcu16 numofhands = outputdata->querynumberofhands(); for(pxcu16 i = 0 ; i < numofhands ; i++) // get hand joints by time of appearence PXCHandData::IHand* handdata; if(outputdata->queryhanddata(pxchanddata::access_order_by_time,i,handdata) == PXC_STATUS_NO_ERROR) // iterate through Joints for(int j = 0; j < PXCHandData::NUMBER_OF_JOINTS ; j++) handdata->querytrackedjoint((pxchanddata::jointtype)j,nodes[i][j]); Intel RealSense SDK Hand Analysis Tutorial 8

Gesture Tracking Initialize the Pipeline 1. Enable the Depth Stream of given size using EnableStream and PXCCapture type. 2. Enable the hand analysis using EnableHand and Initialize the pipeline using Init. 3. Retrieve hand module if ready using QueryHand. 4. Use PXCHandConfiguration to configure and enable all gestures 5. Apply the changes. // select the depth stream of size 640x480 psm->enablestream(pxccapture::stream_type_depth, 640, 480); // enable hand analysis in the multimodal pipeline pxcstatus sts = psm->enablehand(); if (sts < PXC_STATUS_NO_ERROR) wprintf_s(l"unable to enable Hand Tracking\n"); return 2; // retrieve hand results if ready PXCHandModule* handanalyzer = psm->queryhand(); if (!psm) wprintf_s(l"unable to retrieve hand results\n"); return 2; // initialize the PXCSenseManager if(psm->init() < PXC_STATUS_NO_ERROR) return 3; PXCHandData* outputdata = handanalyzer->createoutput(); PXCHandConfiguration* config = handanalyzer->createactiveconfiguration(); config->enableallgestures(); config->applychanges(); 9 Intel RealSense SDK Hand Analysis Tutorial

Stream the Gesture Analysis Data 1. Acquire Frames in a loop using AcquireFrame(true). 2. In every iteration of the frame loop first Update() on the hand module to update the Hand data. 3. Iterate through fired gestures using QueryFiredGesturesNumber and populate the gesture data using QueryFiredGestureData. 4. You can access hand data like QueryBodySide (left or right hand) related to the fired gesture using QueryHandDataByID and gesturedata.handid. The gesture is saved using wmemcpy_s(). Otherwise, gesture data is not saved for current gesture. // stream data while (psm->acquireframe(true)>=pxc_status_no_error) outputdata->update(); // create data structs PXCHandData::GestureData gesturedata; pxcchar gestures[num_hands][pxchanddata::max_name_size] = ; PXCHandData::BodySideType handside[num_hands] = PXCHandData::BODY_SIDE_UNKNOWN; // iterate through fired gestures for(unsigned int i = 0; i < outputdata->queryfiredgesturesnumber(); i++) // initialize data wmemset(gestures[i], 0, sizeof(gestures[i])); handside[i] = PXCHandData::BODY_SIDE_UNKNOWN; // get fired gesture data if(outputdata->queryfiredgesturedata(i,gesturedata) == PXC_STATUS_NO_ERROR) // get hand data related to fired gesture PXCHandData::IHand* handdata; if(outputdata->queryhanddatabyid(gesturedata.handid,handdata) == PXC_STATUS_NO_ERROR) // save gesture only if you know that its right/left hand if(!handdata->querybodyside() == PXCHandData::BODY_SIDE_UNKNOWN) wmemcpy_s (gestures[i],pxchanddata::max_name_size*2, gesturedata.name, sizeof(gesturedata.name)); handside[i] = handdata->querybodyside(); Intel RealSense SDK Hand Analysis Tutorial 10

Alert Event Notifications Initialize the Pipeline 1. Enable the Depth Stream of given size using EnableStream and PXCCapture type. 2. Enable the hand analysis using EnableHand and Initialize the pipeline using Init. 3. Retrieve hand module if ready using QueryHand. 4. Use PXCHandConfiguration to configure and EnableAllAlerts. 5. Apply the changes. // select the color stream of size 640x480 and depth stream of size 320x240 psm->enablestream(pxccapture::stream_type_depth, 640, 480); // enable hand analysis in the multimodal pipeline pxcstatus sts = psm->enablehand(); if (sts < PXC_STATUS_NO_ERROR) wprintf_s(l"unable to enable Hand Tracking\n"); return 2; // retrieve hand results if ready PXCHandModule* handanalyzer = psm->queryhand(); if (!psm) wprintf_s(l"unable to retrieve hand results\n"); return 2; // initialize the PXCSenseManager if(psm->init() < PXC_STATUS_NO_ERROR) return 3; PXCHandData* outputdata = handanalyzer->createoutput(); PXCHandConfiguration* config = handanalyzer->createactiveconfiguration(); config->eenbleallalerts(); config->applychanges(); 11 Intel RealSense SDK Hand Analysis Tutorial

Stream the Alert Notification Data 1. Acquire Frames in a loop using AcquireFrame(true). 2. In every iteration of the frame loop first Update() on the hand module to update the Hand data. 3. Iterate through fired alerts using QueryFiredAlertsNumber and populate the alert data using QueryFiredAlertData. 4. Using alerdata.label you can compare in a switch statement all available alerts under the PXCFaceData alert type. // stream data while (psm->acquireframe(true)>=pxc_status_no_error) outputdata->update(); // iterate through Alerts PXCHandData::AlertData alertdata; for(int i = 0 ; i <outputdata->queryfiredalertsnumber() ; ++i) if(outputdata->queryfiredalertdata(i,alertdata)==pxc_status_no_error) // Display last alert - see AlertData::Label for all available alerts switch(alertdata.label) case PXCFaceData::AlertData:: ALERT_NEW_FACE_DETECTED: wprintf_s(l"last Alert: Face Detected\n", alertdata.faceid); break; case PXCFaceData::AlertData:: ALERT_FACE_LOST: wprintf_s(l"last Alert: Face Not Detected\n", alertdata.faceid); break; Intel RealSense SDK Hand Analysis Tutorial 12

Rendering the Frame 1. Retrieve a sample using QuerySample. 2. Retrieve the specific image or frame type from the sample, by saving it in a variable of type PXCImage. Make sure to enable all the possible required streams in the initializing pipeline phase, if not enabled the sample types will return null. Use the RenderFrame method provided in the custom renderer to render all the above set algorithms. //while loop per frame // retrieve all available image samples PXCCapture::Sample *sample = psm->querysample(); // retrieve the image or frame by type colorim = sample->depth; // render the frame if (!renderer->renderframe(colorim)) break; 13 Intel RealSense SDK Hand Analysis Tutorial

Cleaning up the Pipeline 1. Make sure to ReleaseFrame in every iteration of the while loop, so that you can acquire a fresh frame in the next iteration. 2. Make sure to Release the renderer at the end to delete the FaceRenderer instance. 3. If used, also release any instance of PXCHandConfiguration using Release on it. 4. It is very important to close the last opened session, in this case the instance of PXCSenseManager by using Release to indicate that the camera can stop streaming. //In Main //in the while loop per frame // release or unlock the current frame to go fetch the next frame psm->releaseframe(); //End of while loop per frame // delete the HandRender instance renderer->release(); // close the Hand Configuration instance config->release(); // close the last opened stream and release any session //and processing module instances psm->release(); return 0; //End of Main Intel RealSense SDK Hand Analysis Tutorial 14

Running the Code Sample You can run the code sample two ways: 1. Build and Run the 3_Hands_Analysis sample in Visual Studio*. 2. Run the executables in the Debug subfolder of the code sample directory. Figure 1 shows a rendered depth image frame that displays the hand tracking data as the 22 tracked joints, Alert data, and Gesture Data along with the Body side of each gesture. Figure 1. Rendered Depth Sample with Hand Tracking data, Alert data, and Gesture data To learn more The Intel RealSense SDK Reference Manual is your complete reference guide and contains API definitions, advanced programming techniques, frameworks, and other need-to-know topics. The Intel RealSense SDK allows the hand analysis module to adapt to a user s hand over time. Check out how to save hand calibration data for specific users in the Hand Calibration Data section of the SDK Reference Manual. 15 Intel RealSense SDK Hand Analysis Tutorial