Camera Component

The camera component provides an API for getting images or point clouds.

If you have a physical camera or software that generates 2D images or 3D point clouds, use a camera component.

You can use the camera component to configure a webcam, lidar, time-of-flight sensor, or another type of camera. You can also use camera models to manipulate the output of other cameras to transform, crop, or otherwise change the output.

Error

Configuration

To use a camera with your machine, you need to add it to your machine’s configuration. Go to your machine’s CONFIGURE page, and add a model that supports your camera.

The following list shows the available camera models. The configuration of your camera component depends on your camera model. For additional configuration information, click on the model name:

Model
Description
ModelDescription
fakeA camera model for testing.
esp32-cameraA camera on an ESP32.

API

The camera API supports the following methods:

Method NameDescription
GetImageReturn an image from the camera.
GetImagesGet simultaneous images from different imagers, along with associated metadata.
GetPointCloudGet a point cloud from the camera as bytes with a MIME type describing the structure of the data.
GetPropertiesGet the camera intrinsic parameters and camera distortion, as well as whether the camera supports returning point clouds.
DoCommandExecute model-specific commands that are not otherwise defined by the component API.
GetGeometriesGet all the geometries associated with the camera in its current configuration, in the frame of the camera.
GetResourceNameGet the ResourceName for this camera with the given name.
CloseSafely shut down the resource and prevent further use.

Troubleshooting

If your camera is not working as expected, follow these steps:

  1. Check your machine logs on the LOGS tab to check for errors.

  2. Review your camera model’s documentation to ensure you have configured all required attributes.

  3. Click on the TEST panel on the CONFIGURE or CONTROL tab and test if you can use the camera there.

If none of these steps work, reach out to us on the Community Discord and we will be happy to help.

Common errors

Failed to find the best driver that fits the constraints

When working with a camera component, depending on the camera, you may need to explicitly provide some camera-specific configuration parameters.

Check the specifications for your camera, and manually provide configuration parameters such as width and height to the camera component configuration page on the Viam app. On the CONFIGURE page, find your camera, then fill in your camera’s specific configuration either using the Show more button to show the relevant configuration options, or the {} (Switch to Advanced) button in the top right of the component panel to enter these attributes manually. Provide at least the width and height values to start.

Next steps

For general configuration, development, and usage info, see:

You can also use the camera component with the following services: