Skip to content

Using the Recorded Gestures in your app

Cirill edited this page Mar 9, 2016 · 9 revisions

The recording application provides you with a url to download a .js gesture recognition algorithm file. Download the file and follow the following steps to integrate it into your application.

  • Copy the .js file into your project.

    You may place the file in any folder, just drag and drop the .js file into your project.

  • Create an instance of the Classification class and use your instance of MobileEdgeController to register it.

Example: Register new instance of Classification class

let classification = Classification()

//use the Mobile Edge controller to register the classification
controller.registerInterpretation(classification)
  • Load your .js gesture recognition algorithm file to the classification algorithm:

    Use the function named loadGesturesByNames to load all the gesture recognition algorithm files you want to utilize in your app.

Example: Load the gesture by names

//provide the gesture names without the .js extension 
//if for example you have two gestures HandUp.js and HandDown.js 
//then you should create an array ["HandUp","HandDown"] 
let allGestures = ["gesture_file_name_1","gesture_file_name_2"] 

classification.loadGesturesByNames(allGestures)
  • Register a listener to get notifications when a gesture is detected

    Define a listener that will trigger a function of your choice whenever a gesture is detected.

Example: Register a listener

//register the listener
classification.registerListener(onGestureDetected)

//this method will be called every time some gesture is detected
func onGestureDetected(additonalInfo: AnyObject!) {

   //get the detected gesture name
   let gestureName = additonalInfo["recognized"] as? String

   //get the detected gesture likelihood 
   let score = additonalInfo["score"] as? Int

   //get information about other gestures
   let otherInfo = additonalInfo["others"] as? String

   //define your actions ... 
}
  • Set custom threshold values

    If you have modified the default threshold values during your testing phase, you will need to update those values also in your application.

    For the following example lets say you want to set a threshold value of 1.54 to a gesture named "HandUp".

Example: Set non-default threshold value to a specific gesture

var thresholdValues = Dictionary<String,Double>()
        
//set the value for "HandUp" gesture
thresholdValues["HandUp"] = 1.54

//update the classification with custom values
classification.setSensitivity(thresholdValues)

Clone this wiki locally