.watchers.add
Registers one or more areas to watch with Lampix.
Arguments
...watchers(Watcher[]) Comma separated watcher objects or one level deep arrays of watcher objects.
Returns
(Promise<RegisteredWatcher[]>): A promise that fulfills with a list of RegisteredWatcher objects, equal in length to the number of watcher objects provided to the function
Example
import lampix from '@lampix/core';
const draw = (recognizedObject) => {
// Drawing amazing effects
};
const watcher = {
name: 'DepthClassifier',
shape: lampix.helpers.rectangle(0, 0, window.innerWidth, window.innerHeight),
onClassification: (recognizedObjects) => {
recognizedObjects.forEach(draw);
}
};
lampix.watchers.add(watcher)
.then((registeredWatchers) => {
console.log(registeredWatchers.length); // 1
});Notes
If the method receives arrays, it will concatenate them into a single array that will be sent to Lampix. The promise will be resolved with a single array of watchers, in the same order that they were added. For instance:
Last updated
Was this helpful?