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.
In this page
If you’d like to follow a more detailed tutorial, see Selectively Capture Data Using filtered-camera.
Prerequisites
Collect image data and sync it to the cloud
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.
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.
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.
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.
Avoid fees by disabling data capture
If this is not a production machine and you have confirmed that your machine is capturing and syncing data, disable data capture in the camera configuration to avoid incurring fees for capturing large amounts of test 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:
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.
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.
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
).
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.
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.
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.
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.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!