Configure a Single Stream Camera

A single_stream camera reads from a HTTP server streaming image data.

The server that the model reads from should output an image:

  • If it’s a color image server, then it should output JPEG, PNG, or Viam’s custom color format, image/vnd.viam.rgba.
  • If it’s a depth image server, it should output either a Z16 PNG, or Viam’s custom depth format, image/vnd.viam.dep.

Your single_stream camera can output:

  • A depth stream which outputs a 2D depth map or, if you provide intrinsic_parameters, a point cloud.
  • A color stream which outputs color values in 2D.

Navigate to the Config tab of your robot’s page in the Viam app. Click on the Components subtab and click Create component. Select the camera type, then select the single_stream model. Enter a name for your camera and click Create.

Configuration of a single stream camera in the Viam App config builder.

Edit and fill in the attributes as applicable.

{
    "name": "<your-camera-name>",
    "type": "camera",
    "model" : "single_stream",
    "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>
        },
        "stream": <color|depth>,
        "debug": <boolean>,
        "url": <string>
    }
}

The following attributes are available for single_stream cameras:

NameTypeInclusionDescription
urlstringRequiredThe color or depth stream URL.
intrinsic_parametersobjectOptionalThe intrinsic parameters of the camera used to do 2D <-> 3D projections:
  • width_px: The expected width of the aligned image in pixels.
  • height_px: The expected height of the aligned image in pixels.
  • 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.
streamstringRequiredcolor or depth. The image to be returned when you call Next() or NextPointCloud().
debugbooleanOptionalEnables the debug outputs from the camera if true.
Default: false

If you have a camera that uses its own SDK to access its images and point clouds (like an Intel RealSense camera), you can add a camera server as a remote component of your robot. These remote cameras are treated like any other camera on your robot.

View the camera stream

Once your camera is configured and connected, go to the Control tab, and click on the camera’s dropdown menu. Then toggle the camera or the Point Cloud Data view to ON. If everything is configured correctly, you will see the live video feed from your camera. You can change the refresh frequency as needed to change bandwidth.

Example Camera view inside Viam app

Next Steps



Have questions, or want to meet other people working on robots? Join our Community Discord.