Configure an Image File Camera

An image_file camera gets color and depth image frames or point clouds from a file path on your local system.

Navigate to the CONFIGURE tab of your machine’s page in the Viam app. Click the + icon next to your machine part in the left-hand menu and select Component. Select the camera type, then select the image_file model. Enter a name or use the suggested name for your camera and click Create.

Configuration of an image file camera in the Viam app config builder.

Edit the attributes as applicable to your camera, according to the table below. Note that you must specify at least one of color_image_file_path, depth_image_file_path, and pointcloud_file_path.

{
  "name": "<your-camera-name>",
  "model": "image_file",
  "type": "camera",
  "namespace": "rdk",
  "attributes": {
    "intrinsic_parameters": {
      "width_px": <int>,
      "height_px": <int>,
      "fx": <float>,
      "fy": <float>,
      "ppx": <float>,
      "ppy": <float>
    },
    "distortion_parameters": {
      "rk1": <float>,
      "rk2": <float>,
      "rk3": <float>,
      "tp1": <float>,
      "tp2": <float>
    },
    "color_image_file_path": "<your-file-path>",
    "depth_image_file_path": "<your-file-path>",
    "pointcloud_file_path": "<your-file-path>",
  }
}

The following attributes are available for image_file cameras:

NameTypeRequired?Description
intrinsic_parametersobjectOptionalThe intrinsic parameters of the camera used to do 2D <-> 3D projections:
  • width_px: The expected width of the aligned image in pixels. Value must be >= 0.
  • height_px: The expected height of the aligned image in pixels. Value must be >= 0.
  • fx: The image center x point.
  • fy: The image center y point.
  • ppx: The image focal x.
  • ppy: The image focal y.
distortion_parametersobjectOptionalModified Brown-Conrady parameters used to correct for distortions caused by the shape of the camera lens:
  • rk1: The radial distortion x.
  • rk2: The radial distortion y.
  • rk3: The radial distortion z.
  • tp1: The tangential distortion x.
  • tp2: The tangential distortion y.
color_image_file_pathstringOptionalThe file path to the color image on your local system.
depth_image_file_pathstringOptionalThe file path to the depth image on your local system.
pointcloud_file_pathstringOptionalThe file path to the point cloud file on your local system.

You must specify at least one of color_image_file_path, depth_image_file_path, and pointcloud_file_path.

If you provide configuration for the depth_image_file_path and intrinsic_parameters of the camera, then your machine will also retrieve point cloud data from the depth_image_file_path. If you then also configure a pointcloud_file_path on your camera, Viam will try to pull the data from the pointcloud_file_path first.

View the camera stream

Once your camera is configured and connected, expand the TEST panel on the CONFIGURE or CONTROL tabs. If everything is configured correctly, you will see the live feed from your camera.

Example Camera view inside Viam app

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 this 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.

Solution: 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 more configuration and usage info, see:

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.