Skip to content

About

Viam C++ module for CSI cameras

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

CSI-CAM

A Viam Module for CSI Cameras

Viam Server


CSI Camera Module

Easily integrate CSI Cameras into your Viam projects using this camera module.

The csi-cam module provides one model, viam:camera:csi, which detects the board it runs on and builds the matching GStreamer pipeline.

Supported Boards

  • Nvidia Jetson: links against the GStreamer libraries and Argus plugin that ship with JetPack; nothing else needs to be installed. More Info
  • Raspberry Pi: CSI camera v1.3, v2.0, and v3.0 through the Raspberry Pi OS libcamerasrc plugin, installed on first run. More Info

Currently, the csi-cam module supports the Linux arm64 platforms only.


Usage

To use this module, follow these instructions to add a module from the Viam Registry and select the viam:camera:csi model from the csi-cam module.

Note

Before configuring your camera, you must create a robot.

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 csi model. Enter a name for your camera and click Create.

Configure your CSI camera

On the new component panel, copy and paste the following attribute template into your camera's Attributes box.

{
  "width_px": <int>,
  "height_px": <int>,
  "frame_rate": <int>,
  "video_path": <string>
}

Note

For more information, see Configure a Robot.

Edit the attributes as applicable and save your config. In the Control tab of the Viam app, you can now view the camera feed. If you do not see anything, check the logs tab for errors.

Attributes

The following attributes are available for viam:camera:csi cameras:

Name Type Inclusion Description
width_px int Optional Width of the image this camera captures in pixels.
Default: 1920
height_px int Optional Height of the image this camera captures in pixels.
Default: 1080
frame_rate int Optional The image capture frame rate this camera should use.
Default: 30
video_path string Optional Jetson only. The filepath to the input sensor of this camera on your board. If none is given, your robot will attempt to detect the video path automatically.
Default: "0"
encode_on_request bool Optional Raspberry Pi only. Encode a JPEG only when an image is requested, from the newest frame, instead of encoding every frame. Requests for the same frame share one encode.
Default: false
last_served_frame_for_stream bool Optional Give the live view in the Viam app (viam-server's stream server) the last frame served to a fresh request instead of a fresh frame. With encode_on_request, watching the live view then costs no encodes, but the view only updates when something else requests a frame. It saves nothing without encode_on_request, or on a Jetson, which encodes in hardware.
Default: false

Once configured, check the Logs tab of your robot in the Viam app to make sure your camera has connected and no errors are being raised.

Last served frame

A GetImages request with extra set to {"last_served_frame": true} gets the last frame this camera served to a fresh request, with that frame's capture time, instead of a new frame. It costs no encode, and still errors if the camera has stopped delivering frames. If no frame has been served yet, it gets a fresh one.

viam-server's stream server marks its live-view polling with {"fromStreamServer": true}. With last_served_frame_for_stream, those requests are treated the same way; otherwise, like requests without either key, they get a fresh frame.

Example Configuration

{
  "modules": [
    {
      "type": "registry",
      "name": "viam_csi-cam",
      "module_id": "viam:csi-cam",
      "version": "0.3.0"
    }
  ],
  "components": [
    {
      "model": "viam:camera:csi",
      "attributes": {
        "width_px": 1920,
        "height_px": 1080,
        "frame_rate": 30
      },
      "depends_on": [],
      "name": "csicam_test",
      "namespace": "rdk",
      "type": "camera"
    }
  ]
}

Migrating from csi-cam-pi

The separate csi-cam-pi module is no longer published. In your robot config, change the module's module_id from viam:csi-cam-pi to viam:csi-cam and the component's model from viam:camera:csi-pi to viam:camera:csi. Attributes are unchanged.


Development

Interested in contributing? Check out DEVELOP.md for guidelines on how to build and run the module locally or using docker. We welcome Pull Requests and Issues!

About

Viam C++ module for CSI cameras

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages