Viam makes it easy to capture data on a machine and automatically upload it to the cloud. However, cloud storage costs can add up quickly, and sifting through all of the data when you’re only looking to capture a specific set is a tedious and unnecessary use of your time.
Thankfully, with Viam’s new filtered data feature, you can configure your robot to only upload a specific set of data to the cloud, making it easier and more cost-efficient to store the information you actually need.
As I continue to hack my home to run on Viam, I was particularly excited to use this feature to hack my security camera (which I will describe below), but you can do the same thing for any sensor and save lots of time and money in the process. I also made a video below to show you how Viam’s selective data capture works, using a slightly less personal example to illustrate.
The challenge: Syncing security camera footage only when needed
In my ongoing effort to upgrade my house with Viam, I used an existing security camera to make sure my kids wouldn’t go into the pool without adult supervision.
This is a use case I thought would be perfect for Viam’s new selective data capture feature, so that I could train a camera to only capture data when a specific subject was in its field. In my case, I pointed my camera at the pool and trained it to detect if my kids went in the pool. I then added notifications so I could make sure they had adult supervision upon detection.
The process: Making a smart camera even smarter
To begin this project, I first had to get my camera set up on Viam, which took about 2 minutes. As a bonus, using the recently released Viam mobile app, I was able to see the feed from anywhere at any time.
Next, I needed data to train a model, so I turned on data capture for my camera, pointed it in the direction of my pool, and let it collect data for a while. Then I went into Viam’s data manager, labeled images, and trained a model to detect if people were in the pool.
After that, I set up a computer vision service with that model. I turned off the original data capture and set up a new filtered camera module. For this camera module, I configured the source camera (in this case, the security camera), and the set of conditions under which I wanted an image synced. For this example, that’s the label I created before, with a threshold of 0.8. Once I configured the camera, and it only synced images if someone was in the pool, I added notifications.
I would encourage you to try to write something like this yourself, but of course the point of Viam’s Modular Registry is that since I already did it, you don’t have to. You can get my module here, and if you want a more guided approach, you can also follow this tutorial that teaches you to selectively capture data using my module. If there are other specs that you want, or you don’t like my module for whatever reason, you can also fork it or write your own.
It would in principle be incredibly easy now to add any number of different cameras or sensors into this system and integrate their data too, but for now I’m happy with how this is working. Onto the next household device hack!
Video: Selective data capture in action
Since I don’t want to share videos of my pool, I decided to whip up a quick selective data capture demo in the Viam lab based on the same idea. In this demo, I have a red toy car, and I have trained the CV model to only upload camera data that has the red car in it.
If you’d like to see how the vision service detects a specific object and alerts me, check it out on Github.
As noted above, this selective data capture can be done on any sensor in Viam, and the potential use cases are virtually infinite. I am really excited to see what you might create with it! Sign up to start using Viam for free here.