Composition

Accessors can be composed to create a composite accessor, also known as a 'swarmlet'. As an accessor, the swarmlet itself can be saved and composed with further accessors.

It's common to pair a data acquisition accessor with a data analysis algorithm. Accessors can encapsulate algorithms, too. If there's Javascript code for the browser available, it's usually possible to run everything in the browser host. Alternatively, if the code depends on another host (for example, Node.js) or external cloud service, you can acquire the data in the browser host and use a REST accessor, WebSocket accessor or other data transmission accessor to pipe data to a web service.

For example, let's detect faces in webcam images. The code below instantiates a camera accessor and takes snapshots every 5 seconds for a minute. It's copied from the previous tutorial page.

To detect faces, instantiate a FaceDetector and connect it to the camera.

Click 'instantiate', then 'react to inputs'. The face detector loads the large OpenCV library, so it may be slow to instantiate.

You should see a pair of displays for the camera and a pair of displays for the face detector. Take a selfie and see if your face is detected!

For more algorithms, browse through the accessor library.