.presets.button
Create a watcher object prepared to be used as a button using the standard neural network and watcher name for finger recognition.

Returns

(Watcher): Plain object descriptor for a watcher ready to be registered.

Example

NOTE that all of the ways to create a button specified below are equivalent.
1
import lampix from '@lampix/core';
2
3
const callback = ([recognizedObject]) => {
4
if (Number(recognizedObject.classTag) === 1) {
5
console.log('yay!');
6
} else {
7
console.log('nay!');
8
}
9
};
10
11
// Showcasing how to do it the hard way first
12
const doingThingsTheHardWay = {
13
name: 'NeuralNetworkClassifier',
14
shape: {
15
type: 'rectangle',
16
data: {
17
posX: 50,
18
posY: 50,
19
width: 50
20
height: 50
21
}
22
},
23
onClassification: callback,
24
params: {
25
neural_network_name: 'fingers'
26
}
27
};
28
29
// And the easy way after
30
const doingThingsTheEasyWay = lampix.presets.button(50, 50, callback);
31
32
// Specifying width and height as well
33
const anotherEasyWatcher = lampix.presets.button(50, 50, callback, {
34
width: 50,
35
height: 50
36
});
Copied!
Copy link