How to capture, filter, and sync image data

You can use Viam’s built-in data management service to capture images from a camera on your machine and sync the images to the cloud.

If you want to capture only certain images, such as those containing a person, you can use a “filtering camera” to selectively capture images based on a computer vision model.

With your images synced to the cloud, you can view images from all your machines in one Viam app interface. From there, you can use your image data to do things like train ML models.

Cyclical diagram of a plant watering machine capturing images of plants, syncing those images to the cloud, a machine learning model being trained, and that model being used to recognize yellow leaves on plants and water them.

If you’d like to follow a more detailed tutorial, see Selectively Capture Data Using filtered-camera.


A running machine connected to the Viam app. Click to see instructions.
Add a new machine in the Viam app. Then follow the setup instructions to install viam-server on the computer you’re using for your project and connect to the Viam app. Wait until your machine has successfully connected.

Collect image data and sync it to the cloud

configure a camera component

1. Configure a camera

On your machine’s page, configure any camera component. If you are not sure what to use, start with a webcam.

Collect data

2. Enable the data management service

In your camera component configuration panel, find the Data capture section. Click Add method.

When the Create a data management service prompt appears, click it to add the service to your machine. You can leave the default data manager settings.

Collect data

3. Capture data

With the data management service configured on your machine, you can continue configuring how the camera component itself captures data.

In the Data capture panel of your camera’s config, select Read image from the method selector.

Set your desired capture frequency. For example, set it to 0.05 to capture an image every 20 seconds.

Set the MIME type to your desired image format, for example image/jpeg.

Click save to start capturing data.

Train models

4. View data in the Viam app

Once you have saved your configuration changes, your data will sync at the specified sync interval, which may mean you have to wait and then refresh the page for data to appear.

If no data appears after the sync interval, check the Logs.

Once you have synced images, you can view those images in the Viam app from the DATA tab in the top navigation bar.

You can also export your data from the Viam app to a deployed machine, or to any computer.

You now know how to capture and sync image data.

For many use cases, you may not want to capture data unless it meets certain conditions. Consider the example of a security camera that captures data every 5 seconds. This setup would result in a large number of images, of which most wouldn’t be interesting. In the next part of this guide, you will learn how to filter the data before capturing and syncing it.

Use filtering to collect and sync only certain images

You can use filtering to selectively capture images using a machine learning (ML) model, for example to only capture images with people in them.

Contributors have written several filtering modules that you can use to filter image capture. The following steps use the filtered_camera module:

Train models

1. Add an ML model service to your machine

Add an ML model service on your machine that is compatible with the ML model you want to use, for example TFLite CPU.

Train models

2. Select a suitable ML model

From the Model dropdown on the ML model service configuration panel, select an existing model you want to use, or click Add new model to upload your own. If you’re not sure which model to add, you can add EfficientNet-ImageNet2012 which can detect people and animals, among other things.

Train models

3. Add a vision service to use with the ML model

You can think of the vision service as the bridge between the ML model service and the output from your camera.

Configure the vision / ML model service on your machine. From the Select model dropdown, select the name of your ML model service (for example, mlmodel-1).

Train models

4. Configure the filtered camera

The filtered-camera modular component pulls the stream of images from the camera you configured earlier, and applies the vision service to it.

Configure a filtered-camera component on your machine, following the attribute guide in the README to specify the names of your camera and vision service, and add classification and object detection filters.

Train models

5. Configure data capture and sync on the filtered camera

Configure data capture and sync just as you did before for the physical camera. The filtered camera will only capture image data that passes the filters you configured in the previous step.

Turn off data capture on your camera if you haven’t already, so that you don’t capture duplicate or unfiltered images.

Train models

6. View filtered data in the Viam app

Once you save your configuration, your filtered images will sync and you can view those images in the Viam app from the DATA tab.

Your data will sync at the specified sync interval, which may mean you have to wait and then refresh the page for data to appear.

If no data appears after the sync interval, check the Logs and ensure that the condition for filtering is met. You can add a transform camera to see detections or classifications live from the CONTROL tab.

Train models

7. (Optional) Trigger sync with custom logic

By default, the captured data syncs at the regular interval you specified in the data capture config. If you need to trigger sync in a different way, see Trigger cloud sync conditionally for a documented example of syncing data only at certain times of day.

Next steps

Now that you have collected image data, you can train new computer vision models or programmatically access your data:

To see image data filtering in action, check out these tutorials:

Have questions, or want to meet other people working on robots? Join our Community Discord.

If you notice any issues with the documentation, feel free to file an issue or edit this file.