> ## 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`

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

![main-board](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)

Figure : DIP switches on Dragonwing IQ-9075 Evaluation Kit

| **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> |

Table: DIP settings for cameras

> [!NOTE]
>
> **Note**
>
> For information about how to connect the camera, see Connect camera hardware sensor. This document is available to authorized users only.

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

![pipeline](https://mintcdn.com/qualcomm-prod/taaFSPEtwyRXv4RI/SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/qrb-ros-camera-pipeline1.5.svg?fit=max\&auto=format\&n=taaFSPEtwyRXv4RI\&q=85\&s=c56acb90a447a89cd710c2b7616e4cbe)

## 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](https://dragonwingdocs.qualcomm.com/SDKs/QIR-SDK-2.0/set-up-env-for-sample-app.md).

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

> [accordion] Try me
>
> **1. 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
> ```
>
> **2. 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]
>
> ```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
> ```

## Build and run `qrb_ros_camera`

> [accordion] Try me
>
> **1. 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
> ```
>
> **2. 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/
> ```
>
> **3. 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).

## Limitation

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