How to Configure a Camera
Introduction
Cameras are a key component of many applications, such as computer vision and SLAM. This tutorial shows you how to configure a webcam (sometimes called a USB camera) as a component of your robot.
Connect and configure a webcam
First, you will need to add a webcam to your configuration. In your web browser, navigate to the robot you set up on the Viam app (https://app.viam.com).
Configure the webcam by clicking on the CONFIG tab. Go to the Builder, and create a component with Name “color” of Type “camera” and Model “webcam”.
Once you click Create Component, you’ll see a view on the component that looks like this:
Manually add the camera path to the camera’s attributes and save the config. A good bet is often video0
:
{
"video_path": "video0"
}
If video0
does not work for you, you can find another potential video_path
by typing the following in your terminal:
v4l2-ctl --list-devices
The output for a webcam may look like this example, in which case video1
might be the correct path to input for video_path
:
C270 HD WEBCAM (usb-0000:01:00.0-1.2):
/dev/video0
/dev/video1
/dev/media4
Once your camera is connected, go to the CONTROL tab, and click on the “color” dropdown menu. Toggle “View Camera” and make sure you can see the live video feed from your camera.
General camera troubleshooting
Issue: I can’t see the live video feed
If you’re working on a Pi, ssh
into it, then in the terminal, restart the viam-server
by running:
sudo systemctl restart viam-server
If this doesn’t work, you can reboot your Pi by running:
sudo reboot
or by powering it off and on again.
Issue: The “Export Screenshot” button doesn’t work
- In the CONTROL tab, pick “Manual Refresh” under the “Refresh frequency”.
- Click the refresh button when you’re ready to take an image of the checkerboard.
- Right click on the image, and choose “Save Image As…” to save the image.

Additional troubleshooting
You can find additional assistance in the Troubleshooting section.
You can also ask questions on the Viam Community Slack and we will be happy to help.