Ircam-RnD / motion-features

set of real-time gesture descriptors for accelerometers and gyroscopes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

motion-features

A monoclass library computing a customizable set of gestural descriptors, taking accelerometer and gyroscope sensors data as input.

List of available descriptors :

computed from accelerometer only :

  • accIntensity : gesture intensity computed from the accelerometer
  • kick : detects a hit gesture
  • shake : amount of shakiness of a gesture

computed from gyroscope only :

  • gyrIntensity : gesture intensity computed from the gyroscope
  • spin : the global rotation speed
  • still : tell if the sensors are still

computed from both accelerometer and gyroscope :

  • freefall : tell if the sensors are falling

API documentation :

MotionFeatures

Class computing the descriptors from accelerometer and gyroscope data.
es6 + browserify example :

import { MotionFeatures } from 'motion-features'; 
const mf = new MotionFeatures({ descriptors: ['accIntensity', 'kick'] });

// then, on each motion event :
mf.setAccelerometer(x, y, z);
mf.setGyroscope(alpha, beta, gamma);
mf.update(function(err, res) {
  if (err === null) {
    // do something with res
  }
});

Kind: global class

new MotionFeatures(initObject)

Param Type Description
initObject Object object containing an array of the required descriptors and some variables used to compute the descriptors that you might want to change (for example if the browser is chrome you might want to set gyrIsInDegrees to false because it's the case on some versions, or you might want to change some thresholds). See the code for more details.

motionFeatures.updateParams(params)

Update configuration parameters (except descriptors list)

Kind: instance method of MotionFeatures

Param Type Description
params Object a subset of the constructor's parameters

motionFeatures.setAccelerometer(x, y, z)

Sets the current accelerometer values.

Kind: instance method of MotionFeatures

Param Type Default Description
x Number the accelerometer's x value
y Number 0 the accelerometer's y value
z Number 0 the accelerometer's z value

motionFeatures.setGyroscope(x, y, z)

Sets the current gyroscope values.

Kind: instance method of MotionFeatures

Param Type Default Description
x Number the gyroscope's x value
y Number 0 the gyroscope's y value
z Number 0 the gyroscope's z value

motionFeatures.update(callback) ⇒ features

Triggers computation of the descriptors from the current sensor values and pass the results to a callback

Kind: instance method of MotionFeatures
Returns: features - features - Return these computed descriptors anyway

Param Type Default Description
callback featuresCallback The callback handling the last computed descriptors

accIntensity : Object

Intensity of the movement sensed by an accelerometer.

Kind: global typedef
Properties

Name Type Description
norm Number the global energy computed on all dimensions.
x Number the energy in the x (first) dimension.
y Number the energy in the y (second) dimension.
z Number the energy in the z (third) dimension.

gyrIntensity : Object

Intensity of the movement sensed by a gyroscope.

Kind: global typedef
Properties

Name Type Description
norm Number the global energy computed on all dimensions.
x Number the energy in the x (first) dimension.
y Number the energy in the y (second) dimension.
z Number the energy in the z (third) dimension.

freefall : Object

Information about the free falling state of the sensor.

Kind: global typedef
Properties

Name Type Description
accNorm Number the norm of the acceleration.
falling Boolean true if the sensor is free falling, false otherwise.
duration Number the duration of the free falling since its beginning.

kick : Object

Impulse / hit movement detection information.

Kind: global typedef
Properties

Name Type Description
intensity Number the current intensity of the "kick" gesture.
kicking Boolean true if a "kick" gesture is being detected, false otherwise.

shake : Object

Shake movement detection information.

Kind: global typedef
Properties

Name Type Description
shaking Number the current amount of "shakiness".

spin : Object

Information about the spinning state of the sensor.

Kind: global typedef
Properties

Name Type Description
spinning Boolean true if the sensor is spinning, false otherwise.
duration Number the duration of the spinning since its beginning.
gyrNorm Number the norm of the rotation speed.

still : Object

Information about the stillness of the sensor.

Kind: global typedef
Properties

Name Type Description
still Boolean true if the sensor is still, false otherwise.
slide Number the original value thresholded to determine stillness.

features : Object

Computed features.

Kind: global typedef
Properties

Name Type Description
accIntensity accIntensity Intensity of the movement sensed by an accelerometer.
gyrIntensity gyrIntensity Intensity of the movement sensed by a gyroscope.
freefall freefall Information about the free falling state of the sensor.
kick kick Impulse / hit movement detection information.
shake shake Shake movement detection information.
spin spin Information about the spinning state of the sensor.
still still Information about the stillness of the sensor.

featuresCallback : function

Callback handling the features.

Kind: global typedef

Param Type Description
err String Description of a potential error.
res features Object holding the feature values.

About

set of real-time gesture descriptors for accelerometers and gyroscopes


Languages

Language:JavaScript 100.0%