A monoclass library computing a customizable set of gestural descriptors, taking accelerometer and gyroscope sensors data as input.
computed from accelerometer only :
accIntensity
: gesture intensity computed from the accelerometerkick
: detects a hit gestureshake
: amount of shakiness of a gesture
computed from gyroscope only :
gyrIntensity
: gesture intensity computed from the gyroscopespin
: the global rotation speedstill
: tell if the sensors are still
computed from both accelerometer and gyroscope :
freefall
: tell if the sensors are falling
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
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. |
Update configuration parameters (except descriptors list)
Kind: instance method of MotionFeatures
Param | Type | Description |
---|---|---|
params | Object |
a subset of the constructor's parameters |
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 |
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 |
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. |
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. |
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. |
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 movement detection information.
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
shaking | Number |
the current amount of "shakiness". |
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. |
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. |
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. |
Callback handling the features.
Kind: global typedef
Param | Type | Description |
---|---|---|
err | String |
Description of a potential error. |
res | features |
Object holding the feature values. |