> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Run a zero-copy camera with qrb_ros_camera

The `qrb_ros_camera` sample application implements a camera ROS2 node to enable zero-copy performance when data is coming out of the camera-server. This sample greatly reduces the latency between ROS nodes.

<Note>
  **Note**

  The Dragonwing IQ-9075 Evaluation Kit only supports these cameras:

  * `ov9282`
  * `LI-VENUS-OX03F10-96717-120H camera`
  * `LI-VENUS-OX03F10-OAX40-GM2A-118H camera`
</Note>

## DIP switch operation for connecting to different cameras on Dragonwing IQ-9075

<img src="https://mintcdn.com/qualcomm-prod/IP0o0G5fE3MFmCJ8/SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/qrb-ros-camera_IQ-9075-EVK-main-board.svg?fit=max&auto=format&n=IP0o0G5fE3MFmCJ8&q=85&s=7951b518eeebb5a62440d60eccba4896" alt="main-board" style={{ display: 'block', margin: '0 auto' }} width="878" height="685" data-path="SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/qrb-ros-camera_IQ-9075-EVK-main-board.svg" />

<p style={{ textAlign: 'center', fontWeight: 'bold' }}>
  Figure : DIP switches on Dragonwing IQ-9075 Evaluation Kit
</p>

|                                **DIP settings**                                |                                                **Enabled camera(s)**                                               |
| :----------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------: |
|                             Keeping all pins DOWN.                             |                                                     **ov9282**                                                     |
| Set Pin5, Pin6, Pin7, and Pin8 of SW1 to ON while keeping all other pins DOWN. |             <ul><li>`LI‑VENUS‑OX03F10‑96717‑120H`</li><li>`LI‑VENUS‑OX03F10‑OAX40‑GM2A‑118H`</li></ul>             |
|        Set Pin7 and Pin8 of SW1 to ON while keeping all other pins DOWN.       | <ul><li>`LI‑VENUS‑OX03F10‑OAX40‑GM2A‑118H`</li><li>**ov9282** (when connected to MIPI CSI0 or MIPI CSI1)</li></ul> |

<p style={{ textAlign: 'center', fontWeight: 'bold' }}>
  Table: DIP settings for cameras
</p>

<Note>
  **Note**

  For information about how to connect the camera, see Connect camera hardware sensor. This document is available to authorized users only.
</Note>

## Pipeline flow for `qrb_ros_camera`

The Qualcomm Camera-Server provides camera data that's obtained from the camera sensor. `qrb_ros_camera` uses this camera-server to get the latest camera data.

<img src="https://mintcdn.com/qualcomm-prod/IP0o0G5fE3MFmCJ8/SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/qrb-ros-camera-pipeline1.5.svg?fit=max&auto=format&n=IP0o0G5fE3MFmCJ8&q=85&s=ee345aeb4ce3dd27ce15a52cd242c398" alt="pipeline" style={{ display: 'block', margin: '0 auto' }} width="650" height="258" data-path="SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/qrb-ros-camera-pipeline1.5.svg" />

## ROS nodes used in the `qrb_ros_camera` pipeline

| **ROS node** |                                       **Description**                                       |
| :----------: | :-----------------------------------------------------------------------------------------: |
|   `CAMERA`   | Publishes the `/cam${camera_id}_${stream_name}`, `/cam${camera_id}_camera_info` ROS topics. |

* `camera_id` indicates the camera device ID, with a default value of 0.
* `stream_name` indicates the camera stream names, with a default value of "stream1".

## ROS topics used in the `qrb_ros_camera` pipeline

|           **ROS topic**           |        **Message type**        | **Published/Subscribed by** |          **Description**          |
| :-------------------------------: | :----------------------------: | :-------------------------: | :-------------------------------: |
| `/cam${camera_id}_${stream_name}` |    `sensor_msgs::msg::Image`   |    Published by `camera`.   | Publishes the NV12 encoded image. |
|   `/cam${camera_id}_camera_info`  | `sensor_msgs::msg::CameraInfo` |    Published by `camera`.   | Publishes the camera information. |

## Prerequisites

You have **Set up the device** according to [Set up the environment for running sample applications](./set-up-env-for-sample-app).

## Run out-of-the-box `qrb_ros_camera`

<Accordion title="Try me">
  <Steps>
    <Step title="Run the camera ROS node">
      a. Set CAMX Overlay

      ```bash title="SSH Session" theme={null}
      echo -n "camx" > /var/data
      efivar -n 882f8c2b-9646-435f-8de5-f208ff80c1bd-VendorDtbOverlays -w -f /var/data
      efivar -n 882f8c2b-9646-435f-8de5-f208ff80c1bd-VendorDtbOverlays -p
      sync
      reboot
      ```

      b. Check status

      To confirm that the CamX overlay is active, run the following commands. The script returns `0` when the overlay is applied.

      ```bash title="SSH Session" theme={null}
      /usr/libexec/qmmf-server/check-camx-overlay.sh
      echo $?                   
      ```

      c. Run the `qrb_ros_camera` node.

      ```bash title="SSH Session" theme={null}
      ros2 launch qrb_ros_camera qrb_ros_camera_launch.py
      ```
    </Step>

    <Step title="Get the camera image data">
      a. Set up the QIR SDK and ROS2 environment on the device.

      <Note>
        Value range of `ROS_DOMAIN_ID`: \[0, 232]
      </Note>

      ```bash theme={null}
      ssh root@[ip-addr]
      ```

      ```bash title="SSH Session" theme={null}
      source /usr/share/qirp-setup.sh
      export ROS_DOMAIN_ID=xx
      ```

      b. Verify the ROS topic.

      ```bash title="SSH Session" theme={null}
      ros2 topic echo /cam0_stream1
      ```
    </Step>
  </Steps>
</Accordion>

## Build and run `qrb_ros_camera`

<Accordion title="Try me">
  <Steps>
    <Step title="Build qrb_ros_camera on the host">
      ```bash theme={null}
      cd <qirp_decompressed_workspace>
      source setup.sh
      cd qirp-samples/platform/qrb_ros_camera
      colcon build --merge-install --cmake-args ${CMAKE_ARGS} -DBUILD_TESTING=ON
      ```
    </Step>

    <Step title="Push qrb_ros_camera to the device">
      ```bash theme={null}
      cd qirp-samples/platform/qrb_ros_camera/install
      tar czvf qrb_ros_camera.tar.gz lib share include
      scp qrb_ros_camera.tar.gz root@[ip-addr]:/opt/
      ssh root@[ip-addr]
      ```

      ```bash title="SSH Session" theme={null}
      tar --no-overwrite-dir --no-same-owner -zxf /opt/qrb_ros_camera.tar.gz -C /usr/ros/jazzy/
      ```
    </Step>

    <Step title="Run qrb_ros_camera on the device">
      Follow the steps in [Run out-of-the-box `qrb_ros_camera`](#run-out-of-the-box-qrb_ros_camera).
    </Step>
  </Steps>
</Accordion>

## Limitation

The supported format is NV12 in camera ROS node. Currently, dynamic changes to the image size aren't supported.
