Radio Inspire

How To Learn Sign Language

[Tutorial] Advanced Gesture SDK


Hello, my name is Gab and I’m here to teach you more about the Gesture SDK. Last time you were taught how to build a simple application that uses angular information. This time we’ll look into an app that makes use of the speed and the timestamp feature. Are you ready? So, just to recap on what the Gesture SDK does, let me discuss a few things about it. Gesture enables you to make use of events in your program that are generated by the user’s movements; specifically, data from the gesture sensor on the upper right of your device. This is for the purpose of aiding touch or motion events. Now to get the ball rolling, let’s prepare the things we need. You will need the following items. First, we’ll need Eclipse with ADT plugin. Remember, Jellybean (API level 18) is the minimum requirement to use the Gesture SDK. Next, you are required to have these jar files as well. These can be found in the Mobile SDK archive file. We’ll be working with the Gesture library version 2.0. Third, prepare a Samsung device that has Android 4.3 or higher. And check whether your Samsung smart device has a gesture sensor. Due to hardware issues, Gesture cannot be used with the Galaxy S4. The speed measurements of the hand gesture work in devices with a gesture sensor that provides speed data. Lastly, download the sample application attached to this blog post. For those viewing directly from YouTube, visit developer.samsung.com and check out the tutorial entries. Before we proceed to our sample application, let’s talk about the vital info regarding the Gesture SDK. If you recall our previous episode, we said that hand movement is only captured when the screen is on. This is important when you try to retrieve information through SgestureHand.Info. The architecture consist of Applications, the Gesture and the SContext. Applications refer to one or more applications that make use of Gesture. Gesture refers to components for recognizing hand movements. While the SContext refers to gesture components for providing Motion with gesture events. Wrapping up the steps we did last time, here’s how to initialize Gesture and receive hand movement data: First, Create a Sgesture instance. Then pass the Sgesture instance as a parameter to create a SgestureHand instance. Then call start() to register a ChangeListener instance for the specified hand gesture type. When Gesture starts, SgestureHand sends a callback to the ChangeListener. In the onChanged Info method, we handle the hand gesture events. Then Call stop() to remove the ChangeListener instance. Last February 2014 at MWC, version 1.5 of the Gesture SDK was released. This included the ability for the Gesture SDK to recognize speed in the user’s movement. Speed is measured through the emission of infrared rays that reflect off the user’s hand movement via a transmitter. The speed is measured on a scale of 0 to 100. 0 being the slowest and hundred being the fastest. -1 indicates that the device is not supported. Now, let’s start breaking down our app. Download and import the Wave application in your ADT. Again, you can get this application via the tutorial entries at developer.samsung.com. We can see that the minimum and target SDK is set to API 18 since this is the minimum requirement to use the Gesture SDK. Looking at our manifest permissions, we see we have declared: WRITE_USE_APP_FEATURE_SURVEY This permission doesn’t do anything if you’re working with an API below Kitkat. The main use of this permission is to avoid the security exception thrown for Android 4.4.2. The idea of this application is to mimic a sequence by waving your hand toward the direction of the pattern that was displayed. Let’s look at what each of the classes do. Let’s open Direction.java. This serves as a label for the direction and is called by the GestureHand class. Similar to the simple application we created in the previous episode, GestureHand contains an instance of SgestureHand and SgestureHand.ChangeListener. We access angular data from here. The Randomizer class generates a random pattern sequence for the game while the GameTimer is responsible for calculating the time you have left per level. The GameManager is in charge for directing the player through a simulated run through of the pattern. With the MainGame.java, we see the game come together. Let’s look into it bit by bit. We used the Gesture SDK’s speed feature by calling it inside the ChangeListener that we declared. We add the speed of the player accumulated per level. The average result is retrieved from the check() method after the user has performed the necessary gestures. Going back to the ChangeListener, we make use of the Gesture SDK’s timestamp component. Note that if nPreviousTimeStamp produces a negative value, it retrieves the first instance of the air gesture that was performed. The LastTimeStamp retrieves the last instance of an air gesture that was performed. And both are called inside the check method. We see the lastTimeStamp subtracted to the first instance of the gesture. It produces a result in nanoseconds. That is why we need to divide it by 1e9 to convert it in seconds. Let’s run our application and see how the speed and timestamp features are fully utilized in our game. Open the app. Select “Let’s Play”. The big hallowed area is for instructions. Simply tap on the text to dismiss it. A sequence will be shown. Remember it and beat the timer Now, wave your hand toward the direction of the pattern that was displayed. As you can see, this is a memory game that uses air gestures as input. We see the speed and timestamp feature being used in a way to measure the player’s score. Your rank corresponds to your average speed. If you get a Newbie rank, that means you’re slow and your average gesture speed ranges from 0 to 50. You’re ranked as a Pro if you get 50 to 80. And you’ll get a Ninja rank if you get 80 to 100. We see the use of the timestamp feature to reflect the user’s actual speed. This is seen when the user is prompted with the message “Completed in: ___ seconds”. To sum up the things we learned, let’s have a recap. Don’t forget to: Include the necessary SDK jar files in your project. Next, check if the device supports the Gesture SDK. Note that the hand gesture requires a Samsung Smart Device with a gesture sensor. The speed measurements of the hand gesture work in devices with a gesture sensor that provides speed data. Remember, speed is measured through the emission of infrared rays that reflect off the user’s hand via a transmitter. The speed is measured on a scale of 0 to 100, where 0 is very slow and 100 is very fast. Don’t forget to add the necessary manifest permissions WRITE_USE_APP_FEATURE_SURVEY. We hope this tutorial helped. For inquiries, please post your questions on the official forum at developer.samsung.com. Thanks for watching.

One Reply to “[Tutorial] Advanced Gesture SDK”

Leave a Reply

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