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

# 配置示例应用程序

本节提供了一个灵活的工作流程，用于在 Ubuntu 上使用 Qualcomm® Intelligent Multimedia Product（QIMP）SDK 运行和自定义高级多媒体及 AI 示例应用程序。开发者可以使用 JSON 配置文件定义输入/输出源、运行时目标和模型精度——从而在 CPU、GPU 和 DSP 之间无缝进行评估。凭借对 TFLite、QNN 和 SNPE 等框架的支持以及与 AI Hub 的集成，此环境非常适合构建和优化针对特定用例的边缘 AI 管线。

在 Ubuntu 上使用 **QIMP SDK** 运行高级多媒体和 AI 示例应用程序使开发者能够：

* 在异构计算目标（CPU、GPU、DSP）之间**进行 AI 工作负载的原型开发和验证**，帮助团队为其用例选择最高效的运行时。
* 使用基于 JSON 的配置**自定义应用程序行为**，精确控制输入/输出源、模型类型和运行时参数。
* 通过利用 AI Hub 中预集成的模型以及 TFLite、QNN 和 SNPE 等受支持的框架，**加速开发和部署**。
* **进行性能基准测试并优化资源使用**，这对于计算和功耗预算受限的嵌入式系统和边缘设备至关重要。
* 通过为模型、标签和媒体资源使用标准化的脚本和目录结构，**确保跨 Qualcomm 平台的兼容性和可复现性**。

要开始在您的 Dragonwing 设备上配置示例应用程序，请按照以下分步说明安装所需的依赖项并配置系统。

**前提条件**

* 完成设备设置。
* 确保 IQ‑9075 设备正在运行 Ubuntu 操作系统。
* 设置 Wi-Fi 并通过 SSH 访问 IQ-9075 EVK 设备。
* 基本熟悉 **JSON 配置文件**和运行时环境变量。
* **拥有 AI Hub 访问权限**，以进行模型选择和导出。
  * 如果您还没有账户，请[**创建 AI Hub 账户**](https://aihub.qualcomm.com/)
* 如果尚未安装 PPA 软件包，请执行**安装所需软件包**步骤。

## 安装所需软件包

要安装所需的预构建软件包，请参阅[**🔗安装所需软件包**](../devices/iq9075-evk/Install_required_software_packages)章节，并运行提供的"Install PPA Packages"脚本。

## 下载并运行工件脚本

在运行任何示例应用程序之前，您必须下载所需的模型、标签和媒体资源。`download_artifacts.sh` 脚本会自动获取所有必需的组件，包括：

* 模型 – 示例应用程序用于推理的预训练机器学习模型。
* 标签 – 将模型输出映射为人类可读类别名称的元数据文件。
* 媒体文件 – 用于运行和验证应用程序的示例输入数据（如图像或视频）。

您可以通过 SSH 或在设备本地登录后运行以下命令。

```shell theme={null}
cd /home/ubuntu 
curl -L -O https://raw.githubusercontent.com/quic/sample-apps-for-qualcomm-linux/refs/heads/main/qualcomm-linux/scripts/download_artifacts.sh
sudo chmod +x download_artifacts.sh 
sudo ./download_artifacts.sh
```

## 验证模型/标签/媒体文件

在启动任何示例应用程序之前，请确保所需文件已就位。

#### 检查以下目录：

* **模型文件** → `/etc/models/`
* **标签文件** → `/etc/labels/`
* **媒体文件** → `/etc/media/`

<Note>
  **注意：**  这些文件对于 AI 示例应用程序的正常运行至关重要。如果缺失，请重新运行工件下载脚本。
</Note>

## 更新 JSON 配置文件

要以特定功能运行示例应用程序，您需要一个正确配置的 JSON 文件。

### 要做什么

* 根据您的**模型**和**配置需求**更新所需的 JSON 配置文件。

### 配置参数

| 参数    | 选项                             |
| ----- | ------------------------------ |
| 输入源   | 摄像头、文件（Filesrc）、RTSP 流         |
| 输出源   | Waylandsink、Filesink、RTSP 流    |
| 运行时选项 | CPU、GPU、DSP                    |
| 精度    | INT8 或 INT16、W8A8 或 W8A16、FP32 |
| 模型类型  | 从 **AI Hub** 的可用模型中选择          |
| 标签    | 选择正确的标签文件                      |

**示例 1：**\
***gst-ai-multistream-inference*** 应用程序演示了对最多 32 个来自摄像头、文件或 RTSP 流的输入流进行 AI 推理（目标检测和分类）。

要使用 32 个 H.264 文件输入运行多流推理示例应用程序进行目标检测，并在 Wayland 显示器上显示输出，请将所有 32 个流的输入文件路径配置为引用 /etc/media/video.mp4。打开相应的 `config-multistream-inference.json` 文件并应用所需的更改。

```shell theme={null}
sudo vi /etc/configs/config-multistream-inference.json
```

```shell theme={null}
{
  "input-file-path":
    [
      "/etc/media/video.mp4",
      "/etc/media/video.mp4",
      "/etc/media/video.mp4",
      "/etc/media/video.mp4",
      .......
       "/etc/media/video.mp4",
    ]
}
```

**示例 2：**\
`gst-ai-object-detection` 应用程序可用于检测图像和视频中的对象。要将输入源设置为实时摄像头画面，请按如下方式配置输入源

```bash theme={null}
#Primary
"camera":0
#Secondary
"camera":1
```

## 运行示例应用程序

要运行示例应用程序，请执行以下操作：

1. 使用 SSH 或 SBC 终端启动示例应用程序。
2. 设置所需的环境变量，将 Wayland 应用程序连接到当前的用户会话。

```bash theme={null}
export XDG_RUNTIME_DIR=/run/user/$(id -u ubuntu)
export WAYLAND_DISPLAY=wayland-1
```

3. 对于 Desktop 构建：\
   运行以下额外命令以创建缺失的符号链接（针对 TensorFlow Lite C 库）。

```bash theme={null}
sudo ln -s /lib/aarch64-linux-gnu/libtensorflowlite_c.so.2 /lib/aarch64-linux-gnu/libtensorflowlite_c.so
```

4. 运行示例应用程序。\\

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

**gst-ai-multistream-inference 管线：**

<img src="https://mintlify.s3.us-west-1.amazonaws.com/qualcomm-prod/images/run-sample-applications/IQ-9075_gst-ai-multistream-inference.png" alt="" />

**预期输出：**

<img src="https://mintlify.s3.us-west-1.amazonaws.com/qualcomm-prod/images/run-sample-applications/IQ9075_AI_multistream_inference.png" alt="" />

5. 要显示可用的帮助选项，请在 SSH shell 中运行以下命令：

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

**调试消息：**\
设置 GStreamer 用于控制调试消息详细程度和类别的 GST\_DEBUG 环境变量。

```shell theme={null}
export GST_DEBUG=3
```

6. 要停止应用程序，请按 **CTRL + C**

## 示例应用程序配置矩阵

| 示例应用名称                                     | 详情                                                                                                                           | AI Hub 模型类型                                                                                                                   | 运行时         | 使用脚本                                                                                                                                                                                                                                                |
| ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| gst-ai-classification                      | [图像分类](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/gst-ai-classification.html)                        | MobileNet-v2, ResNet101, GoogLeNet, MobileNet-v3-Large, ResNet18, ResNeXt50, ResNeXt101, SqueezeNet, WideResNet50, Shufflenet | CPU、GPU、DSP | [更新 JSON](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-sample-apps/gst-ai-classification/config_classification.json?ref_type=heads)                                      |
| gst-ai-object-detection                    | [目标检测](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/gst-ai-object-detection.html)                      | Yolox, Yolov7, Yolov8-Detection（手动导出）                                                                                         | CPU、GPU、DSP | 从 AI Hub 导出模型；针对 Yolox/Yolov7 更新脚本 – [更新 JSON](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-sample-apps/gst-ai-classification/config_classification.json?ref_type=heads) |
| gst-ai-pose-detection                      | [姿态检测](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/gst-ai-pose-detection.html)                        | hrnet\_pose                                                                                                                   | CPU、GPU、DSP | TFLite 默认可用；针对精度/运行时更新脚本 – [更新 JSON](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-sample-apps/gst-ai-classification/config_classification.json?ref_type=heads)           |
| gst-ai-segmentation                        | [图像分割](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/gst-ai-segmentation.html)                          | FFNet-40S, FFNet-54S, FFNet-78S                                                                                               | CPU、GPU、DSP | [更新 JSON](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-sample-apps/gst-ai-classification/config_classification.json?ref_type=heads)                                      |
| gst-ai-superresolution                     | [视频超分辨率](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/video-super-resolution.html)                     | quicksrnetsmall, QuickSRNetMedium, QuickSRNetLarge, XLSR                                                                      | CPU、GPU、DSP | [更新 JSON](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-sample-apps/gst-ai-classification/config_classification.json?ref_type=heads)                                      |
| gst-ai-multistream-batch-inference         | [多流批量推理](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/multistream-batch-inference.html)                | YoloV8-Detection（批量 4）, DeeplabV3（批量 4）                                                                                       | CPU、GPU、DSP | 从 AI Hub 导出模型；更新脚本 – [更新 JSON](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-sample-apps/gst-ai-classification/config_classification.json?ref_type=heads)                 |
| gst-ai-face-detection                      | [人脸检测](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/gst-ai-face-detection.html)                        | face\_det\_lite                                                                                                               | CPU、GPU、DSP | [更新 JSON](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-sample-apps/gst-ai-classification/config_classification.json?ref_type=heads)                                      |
| gst-ai-face-recognition                    | [人脸识别](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/gst-ai-face-recognition.html)                      | face\_det\_lite, face\_attrib\_net, facemap\_3dmm                                                                             | CPU、GPU、DSP | 需要人脸注册；否则输出为 'unknown face recognized'                                                                                                                                                                                                              |
| gst-ai-metadata-parser-example             | [元数据解析](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/gst-ai-metadata-parser.html)                      | Yolov8-Detection                                                                                                              | CPU、GPU、DSP | 从 AI Hub 导出模型                                                                                                                                                                                                                                       |
| gst-ai-usb-camera-app                      | [AI USB 摄像头](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/gst-ai-metadata-parser.html)                 | Yolov8-Detection                                                                                                              | CPU、GPU、DSP | 从 AI Hub 导出模型                                                                                                                                                                                                                                       |
| gst-ai-parallel-inference                  | [并行推理](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/gst-ai-parallel-inference.html)                    | Yolov8-Detection, Deeplab, Hrnet, Inceptionv3                                                                                 | CPU、GPU、DSP | 从 AI Hub 导出模型；针对其他模型 [更新 JSON](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-sample-apps/gst-ai-classification/config_classification.json?ref_type=heads)                 |
| gst-ai-daisychain-detection-classification | [菊花链检测与分类](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/daisy-chain-detection-and-classification.html) | Inceptionv3 + YoloV8                                                                                                          | CPU、GPU、DSP | 从 AI Hub 导出模型；针对其他模型 [更新 JSON](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-sample-apps/gst-ai-classification/config_classification.json?ref_type=heads)                 |
| gst-ai-audio-classification                | [音频分类](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/audio-classification.html)                         | Inceptionv3 + YoloV8                                                                                                          | CPU、GPU、DSP | 从 AI Hub 导出模型；针对其他模型 [更新 JSON](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-sample-apps/gst-ai-classification/config_classification.json?ref_type=heads)                 |
| gst-ai-smartcodec-example                  | [AI 智能编解码器](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/ai-smart-codec.html)                          | Inceptionv3 + YoloV8                                                                                                          | CPU、GPU、DSP | 从 AI Hub 导出模型；针对其他模型 [更新 JSON](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-sample-apps/gst-ai-classification/config_classification.json?ref_type=heads)                 |

## 参考文档

要进一步探索示例应用程序，请参阅 Qualcomm Intelligent Multimedia SDK（IM SDK）参考指南。[Qualcomm Intelligent Multimedia SDK（IM SDK）参考](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-50/example-applications.html)
