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

# 运行示例应用程序

> 在 Qualcomm Device Cloud 设备上运行预装的基于 GStreamer 的 AI 示例应用程序

Qualcomm Dragonwing™ RB3 Gen 2 设备预装了基于 GStreamer 的 AI 示例应用程序。其中一些应用程序支持 RTSP 输入（例如来自 IP 摄像头）以及可在主机上查看的 RTSP 输出。

## 运行多流推理示例应用程序

`gst-ai-multistream-inference` 应用程序演示了对来自摄像头、文件或 RTSP 源的最多 8 路组合输入流进行 AI 推理（目标检测和分类）。输出可以显示在 HDMI 显示器上、保存为 H.264 编码的 MP4 文件，或以 RTSP 输出的形式进行流式传输。

1. 从 [Qualcomm AI Hub](https://aihub.qualcomm.com/) 下载 YoloX 和 InceptionV3 量化模型并将其复制到设备。

2. 从主机终端将模型和输入视频文件复制到设备：

   ```shell theme={null}
   scp -P 2222 -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null <model file path> root@localhost:/etc/models/
   ```

   ```shell theme={null}
   scp -P 2222 -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null <video file path> root@localhost:/etc/media/
   ```

3. 在 QDC 设备 shell 上，下载并解压标签文件：

   ```shell theme={null}
   wget https://github.com/quic/sample-apps-for-qualcomm-linux/releases/download/labels/labels.zip
   unzip -d /etc/ labels.zip
   ```

4. 在设备上创建 `/etc/xdg/weston` 目录：

   ```shell theme={null}
   mkdir /etc/xdg/weston
   ```

5. 在设备上创建或编辑 `/etc/xdg/weston/weston.ini` 文件：

   ```ini theme={null}
   # configuration file for Weston
   [core]
   idle-time=0
   # backend=sdm-backend.so
   repaint-window=10
   gbm-format=xbgr8888
   require-outputs=none

   [output]
   name=DSI-1
   mode=on

   [output]
   name=DP-1
   mode=on

   [shell]
   clock-format=seconds
   ```

6. 编辑 `/etc/configs/config-multistream-inference.json` 配置文件。

   对于 RTSP 输入和 RTSP 输出：

   ```json theme={null}
   {
     "input-rtsp-path": [
       "rtsp://127.0.0.1:8901/live1.mkv"
     ],
     "model": "/etc/models/yolox_quantized.tflite",
     "labels": "/etc/labels/yolox.json",
     "output-display": 0,
     "output-ip-address": "127.0.0.1",
     "output-port-number": "8900",
     "use-case": 0
   }
   ```

   `input-rtsp-path` 字段是一个 RTSP 输入地址的 JSON 数组。输出流地址为 `rtsp://<output-ip-address>:<output-port-number>/live`。

   对于文件输入和文件输出：

   ```json theme={null}
   {
     "input-file-path": [
       "/etc/media/video1.mp4",
       "/etc/media/video2.mp4",
       "/etc/media/video3.mp4",
       "/etc/media/video4.mp4",
       "/etc/media/video5.mp4",
       "/etc/media/video6.mp4"
     ],
     "model": "/etc/models/yolox_quantized.tflite",
     "labels": "/etc/labels/yolox.json",
     "input-type": "h264",
     "output-display": 0,
     "output-file-path": "<output file path>",
     "use-case": 0
   }
   ```

   `input-file-path` 字段是一个输入文件路径的 JSON 数组。输出保存到 `output-file-path` 中指定的路径。

7. 运行示例应用程序：

   ```shell theme={null}
   gst-ai-multistream-inference
   ```

   要查看完整的配置选项列表，请运行：

   ```shell theme={null}
   gst-ai-multistream-inference -h
   ```

8. 查看或复制输出：

   <Tabs>
     <Tab title="文件输出">
       将输出文件复制到您的主机：

       ```shell theme={null}
       scp -P 2222 -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null root@localhost:<output file path> ./
       ```
     </Tab>

     <Tab title="RTSP 输出">
       使用 VLC 媒体播放器查看输出：

       1. 打开 VLC 媒体播放器。
       2. 按 `Ctrl+N`。
       3. 在输入栏中输入 URL `rtsp://127.0.0.1:8900/live`。
       4. 选择 **Play**。

       <img src="https://mintlify.s3.us-west-1.amazonaws.com/qualcomm-prod/zh/Tools/Qualcomm-Device-Cloud/_images/qdc/sample-app-rtsp-output.png" alt="VLC 中的示例应用程序 RTSP 输出" />
     </Tab>
   </Tabs>

有关更多信息，请参阅[多流推理](https://docs.qualcomm.com/doc/80-80022-55/topic/multistream-inference.html)。

## 运行多输入目标检测示例应用程序

`gst-ai-multi-input-output-object-detection` 应用程序对来自各种来源（例如文件或 RTSP 流）的视频流执行目标检测。输出可以显示在 HDMI 显示器上、保存为 H.264 编码的 MP4 文件，或以 RTSP 输出的形式进行流式传输。

1. [生成 yolov5.tflite 模型并下载标签文件](/zh/Key-Documents/AI-Developer-Workflow/topic/appx-export-yolov8)。

2. 将模型和输入视频文件复制到设备：

   ```shell theme={null}
   scp -P 2222 -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null <model file path> root@localhost:/etc/models/
   ```

   ```shell theme={null}
   scp -P 2222 -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null <video file path> root@localhost:/etc/media/
   ```

3. 在 QDC 设备 shell 上，下载并解压标签文件：

   ```shell theme={null}
   wget https://github.com/quic/sample-apps-for-qualcomm-linux/releases/download/labels/labels.zip
   unzip -d /etc/ labels.zip
   ```

4. 如果尚未完成，请在设备上创建 `/etc/xdg/weston` 目录：

   ```shell theme={null}
   mkdir /etc/xdg/weston
   ```

5. 如果尚未完成，请在设备上编辑 `/etc/xdg/weston/weston.ini` 文件：

   ```ini theme={null}
   # configuration file for Weston
   [core]
   idle-time=0
   # backend=sdm-backend.so
   repaint-window=10
   gbm-format=xbgr8888
   require-outputs=none

   [output]
   name=DSI-1
   mode=on

   [output]
   name=DP-1
   mode=on

   [shell]
   clock-format=seconds
   ```

6. 编辑 `/etc/configs/config-multi-input-output-object-detection.json` 配置文件。

   对于文件输入和文件输出：

   ```json theme={null}
   {
     "input-file-path": [
       "/etc/media/video1.mp4",
       "/etc/media/video2.mp4"
     ],
     "model": "/etc/models/yolov5.tflite",
     "labels": "/etc/labels/yolov5.json",
     "output-file-path": "/etc/media/output.mp4"
   }
   ```

   对于文件输入和 RTSP 输出：

   ```json theme={null}
   {
     "input-file-path": [
       "/etc/media/video1.mp4",
       "/etc/media/video2.mp4"
     ],
     "model": "/etc/models/yolov5.tflite",
     "labels": "/etc/labels/yolov5.json",
     "output-ip-address": "10.92.176.104",
     "output-port-number": "8900"
   }
   ```

7. 运行示例应用程序：

   ```shell theme={null}
   gst-ai-multi-input-output-object-detection --config-file=/etc/configs/config-multi-input-output-object-detection.json
   ```

8. 查看或复制输出：

   <Tabs>
     <Tab title="文件输出">
       将输出文件复制到您的主机：

       ```shell theme={null}
       scp -P 2222 -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null root@localhost:<output file path> ./
       ```
     </Tab>

     <Tab title="RTSP 输出">
       使用 VLC 媒体播放器查看输出：

       1. 打开 VLC 媒体播放器。
       2. 按 `Ctrl+N`。
       3. 在输入栏中输入 URL `rtsp://127.0.0.1:8900/live`。
       4. 选择 **Play**。

       <img src="https://mintlify.s3.us-west-1.amazonaws.com/qualcomm-prod/zh/Tools/Qualcomm-Device-Cloud/_images/qdc/sample-app-rtsp-output.png" alt="VLC 中的示例应用程序 RTSP 输出" />
     </Tab>
   </Tabs>

有关更多信息，请参阅[多输入推理](https://docs.qualcomm.com/doc/80-80022-55/topic/multi-input-inferencing.html)。
