Skip to content

Instantly share code, notes, and snippets.

@yungookim
Last active August 29, 2015 14:23
Show Gist options
  • Save yungookim/d9daf299396d645822df to your computer and use it in GitHub Desktop.
Save yungookim/d9daf299396d645822df to your computer and use it in GitHub Desktop.
Initializing kiwi-library-web
'use strict'
// callback for sensor data. At sample rate of 50hz,
// this function will be called 50 times per second.
// i.e. every 20ms
var onData = function(data){
/*
Structure of data :
data = {
// Accelerometer x, y, z
ax : float,
ay : float,
az : float,
// Gyroscope x, y, z
gx : float,
gy : float,
gz : float
}
*/
}
// callback invoked once a motion is detected.
// This is what you will want to use.
var onMotion = function(motion){
var motionName = motion.motion_name;
};
// callback whenever the motion scores are updated.
var onSCore = function(scores){
/*
scores is an array of objects that contains
each motion's unique id, name of the motion,
how close the current user input is to the
listening motions.
Structure
scores = [
{
motion_id : 'some unique random id',
motion_name : 'flick',
score : float // a quantitative comparison metric between user's motion input and loaded motion model.
threshold : int // Defines the sensitivity of the scoring system.
// The higher it is, it's more likely to detect a motion, however more false positives.
confidence : float // A decimal between 0 ~ 1. Similar to score above. However in percentage.
// Denotes percentage of a match between user's motion input and loaded motion model.
},
..
]
*/
};
// Initialization :
// deviceId : Any unique token can be used to synchronize between multiple devices via socket.io data stream.
// onData : optional. See above for description.
// onMotion : optional. See above for description.
// onScore : optional. See above for description.
KIWI.KiwiWebClient(deviceId, onData, onMotion, onScore);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment