# Python 应用程序

Source: [https://docs.qualcomm.com/doc/80-70017-50SC/topic/python-sample-applications.html](https://docs.qualcomm.com/doc/80-70017-50SC/topic/python-sample-applications.html)

Qualcomm Linux 通过 [gstreamer1.0-python](https://git.codelinaro.org/clo/le/meta-qti-gst/-/blob/imsdk.lnx.2.0.0.r2-rel/recipes-gst/packagegroups/packagegroup-qcom-gst.bb?ref_type=heads#L45) 软件包提供了对 Python 的集成支持。Qualcomm IM SDK 支持 Python 绑定，允许用户在 Python 中创建基于 GStreamer 的应用程序。所有 GST 插件的 Python 绑定均通过 `gst-python` 实用工具启用。

使用 Python 运行自定义用例，以使用Qualcomm Linux 的多媒体和 AI/ML 功能。
注释： 作为参考，本指南中提供了带有 Python 绑定的基于 Python 的示例应用程序。

## 前提条件

- 要在设备上创建目录，请在 shell 中运行以下命令：

        mount -o remount,rw /Copy to clipboard

        mkdir -p /opt/data/Copy to clipboard
- 确保模型和标签文件在设备上可用。相关说明，可参见 [下载 LiteRT 和 Qualcomm AI Engine Direct 的模型、标签和 config JSON 文件](https://docs.qualcomm.com/doc/80-70017-50SC/topic/ai-ml-sample-applications.html#ai-ml-sample-applications__section_fsl_lgz_scc)。
- 确保根据所使用的应用程序重命名模型和标签文件。
- 启用显示屏：

        export XDG_RUNTIME_DIR=/dev/socket/weston && export WAYLAND_DISPLAY=wayland-1Copy to clipboard
- 将文件从主机推送至目标设备：

        scp <video.mp4> root@<IP address of target device>:/opt/data/Copy to clipboard

## Python 应用程序的源信息

| 应用程序 | CodeLinaro Git - 源代码路径 | 演示 | 支持的 SoC |
| --- | --- | --- | --- |
| [摄像头编码](https://docs.qualcomm.com/doc/80-70017-50SC/topic/camera-encode.html) | [gst-camera-encode.py](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-camera-encode.py?ref_type=heads) | 对单个摄像头流进行编码并 dump 输出。 | QCS6490 |
| [使用 Python 的多摄像头流](https://docs.qualcomm.com/doc/80-70017-50SC/topic/multi-camera-streaming-python-sample-app.html) | [gst-multi-camera-example](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-multi-camera-stream-example.py?ref_type=heads) | 同时从两个摄像头传感器进行数据流传输。 | QCS6490 |
| [使用 Python 并发视频播放（视频墙）](https://docs.qualcomm.com/doc/80-70017-50SC/topic/video-wall-using-python.html) | [gst-concurrent-videoplay-composition.py](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-concurrent-videoplay-composition.py?ref_type=heads) | 支持同时播放视频并将其呈现在屏幕上。 | QCS6490 |
| [使用 Python 并发视频播放（视频墙）](https://docs.qualcomm.com/doc/80-70017-50SC/topic/video-wall-using-python.html) | [gst-concurrent-videoplay-composition.py](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-concurrent-videoplay-composition.py?ref_type=heads) | 支持同时播放视频并将其呈现在屏幕上。 | QCS9075 |
| [使用 Python 并发视频播放（视频墙）](https://docs.qualcomm.com/doc/80-70017-50SC/topic/video-wall-using-python.html) | [gst-concurrent-videoplay-composition.py](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-concurrent-videoplay-composition.py?ref_type=heads) | 支持同时播放视频并将其呈现在屏幕上。 | QCS8275 |
| [目标检测与显示](https://docs.qualcomm.com/doc/80-70017-50SC/topic/camera-detection-display.html) | [gst-ai-object-detection.py](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-ai-object-detection.py) | 对来自摄像头或文件源的流进行目标检测，并将输出显示或保存至文件中。 | QCS6490 |
| [使用 RTSP 流进行解码和目标检测](https://docs.qualcomm.com/doc/80-70017-50SC/topic/rts-decode-ai-detection-yolo-v8-overlay-display.html) | [gst-rtspsrc-detection-display.py](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-rtspsrc-detection-display.py) | 使用来自 RTSP 流的输入进行目标检测和显示。 | QCS6490 |
| [目标检测和分类](https://docs.qualcomm.com/doc/80-70017-50SC/topic/camera-ai-detection-overlay-composer-display.html) | [gst-camera-two-stream-detection-and-classification-side-by-side.py](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-camera-two-stream-detection-and-classification-side-by-side.py?ref_type=heads) | AI 叠加编辑器显示的场景中的目标检测和对象分类。 | QCS6490 |
| [转换和编码摄像头流](https://docs.qualcomm.com/doc/80-70017-50SC/topic/camera-transform-downscale-and-rotate-encode.html) | [gst-camera-rotate-downscale-file.py](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-camera-rotate-downscale-file.py?ref_type=heads) | 旋转、缩小和编码摄像头流。 | QCS6490 |
| [摄像头编码、目标检测和显示](https://docs.qualcomm.com/doc/80-70017-50SC/topic/camera-encode-file-detection-yolov8-overlay-display.html) | [gst-camera-two-stream-encode-file-detection-display.py](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-camera-two-stream-encode-file-detection-display.py?ref_type=heads) | 对摄像头流进行编码并将其保存至文件中。 | QCS6490 |
| [目标检测、分类和分割](https://docs.qualcomm.com/doc/80-70017-50SC/topic/object-detection-classification-and-segmentation-python-sample-app.html) | [gst-filesrc-2detection-classification-segmentation-side-by-side.py](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-filesrc-2detection-classification-segmentation-side-by-side.py?ref_type=heads) | 从摄像头流中的场景进行目标检测、对视频流中的场景进行分类以及视频的语义分割。 | QCS6490 |
| [使用 Python 进行并行推理](https://docs.qualcomm.com/doc/80-70017-50SC/topic/parallel-inference-using-python.html) | [gst-parallel-inference.py](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-parallel-inference.py?ref_type=heads) | 多个 AI/ML 模型在来自摄像头、文件源或 RTSP 的流上并行运行（目标检测、分类、分割和姿态检测）。 | QCS6490 |
| [使用 Python 进行菊花链检测和姿态检测](https://docs.qualcomm.com/doc/80-70017-50SC/topic/daisy-chain-detection-and-pose-detection-using-python.html) | [gst-ai-daisychain-detection-pose.py](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-python-examples/gst-daisychain-detection-pose.py?ref_type=heads) | 使用摄像头源、文件源或 RTSP 流执行级联目标检测和姿态检测。 | QCS6490 |
|  |  |  |  |
|  |  |  |  |

## 示例应用程序支持的输入源

Table : 支持的输入源

| SoC | 摄像头输入 | 文件输入 | RTSP 输入 |
| :--- | :--- | :--- | :--- |
| QCS6490 | ✔ | ✔ | ✔ |
| QCS9075 | ❌ | ✔ | ✔ |
| QCS8275 | ❌ | ✔ | ✔ |

- **[摄像头编码](https://docs.qualcomm.com/doc/80-70017-50SC/topic/camera-encode.html)**  

**gst-camera-encode-example** 应用程序允许用户记录和编码单个摄像头流。
- **[使用 Python 并发视频播放（视频墙）](https://docs.qualcomm.com/doc/80-70017-50SC/topic/video-wall-using-python.html)**  

此 **gst-concurrent-videoplay-composition.py** 程序支持 MP4 AVC（H.264）视频的并发视频播放，并在视频墙显示器上执行合成。
- **[使用 Python 的多摄像头流](https://docs.qualcomm.com/doc/80-70017-50SC/topic/multi-camera-streaming-python-sample-app.html)**  

**gst-multi-camera-example.py**应用程序可让用户同时从两个摄像头传感器进行流传输。该应用将摄像头馈送的图像数据并排进行合成并显示在屏幕上，或将视频流编码并存储到文件中。
- **[目标检测与显示](https://docs.qualcomm.com/doc/80-70017-50SC/topic/camera-detection-display.html)**  

**gst-ai-object-detection.py** 应用程序可让用户检测摄像头流或文件流中的对象并显示结果或将输出保存到文件中。
- **[使用 RTSP 流进行解码和目标检测](https://docs.qualcomm.com/doc/80-70017-50SC/topic/rts-decode-ai-detection-yolo-v8-overlay-display.html)**  

**gst-rtspsrc-detection-display.py** 脚本接收 RTSP 流作为源，对其进行解码，使用 [YOLOv8](https://github.com/ultralytics/ultralytics) LiteRT 模型从摄像头流中识别场景中的对象，并将边界框覆盖在检测到的对象上。结果显示在显示屏上。
- **[目标检测和分类](https://docs.qualcomm.com/doc/80-70017-50SC/topic/camera-ai-detection-overlay-composer-display.html)**  

**gst-camera-two-stream-detection-and-classification-side-by-side.py** 应用程序使用 YOLOv8 LiteRT 模型来检测和分类 AI Overlay Composer 显示的场景中的对象。
- **[转换和编码摄像头流](https://docs.qualcomm.com/doc/80-70017-50SC/topic/camera-transform-downscale-and-rotate-encode.html)**  

**gst-camera-rotate-downscale-file.py** 应用程序可旋转、缩小摄像头流并对其进行编码。然后将转换后的数据流保存到文件中。
- **[摄像头编码、目标检测和显示](https://docs.qualcomm.com/doc/80-70017-50SC/topic/camera-encode-file-detection-yolov8-overlay-display.html)**  

**gst-camera-two-stream-encode-file-detection-display.py** 应用程序对摄像头流进行编码并将其保存到文件中。该应用程序使用 YOLOv8 LiteRT 模型从摄像头流中识别场景中的对象。应用程序将边界框覆盖在检测到的对象上并显示结果。
- **[目标检测、分类和分割](https://docs.qualcomm.com/doc/80-70017-50SC/topic/object-detection-classification-and-segmentation-python-sample-app.html)**  

**gst-filesrc-2detection-classification-segmentation-side-by-side.py** 脚本从摄像头流中的场景中识别对象，将边界框覆盖在检测到的对象上，从视频流中对场景进行分类，并对视频进行语义分割。输出并排显示在屏幕上。
- **[使用 Python 进行并行推理](https://docs.qualcomm.com/doc/80-70017-50SC/topic/parallel-inference-using-python.html)**  

**gst-parallel-inference.py** 应用程序接收来自摄像头、文件或 RTSP 流的视频输入，并将其发送到 AI 模型的四个通道进行并行处理（分类、目标检测、姿态检测和分割）。输出显示为带有叠加 AI 模型的预览。
- **[使用 Python 进行菊花链检测和姿态检测](https://docs.qualcomm.com/doc/80-70017-50SC/topic/daisy-chain-detection-and-pose-detection-using-python.html)**  

**gst-ai-daisychain-detection-pose.py**应用程序使用户能够使用来自摄像头、文件源或 RTSP 流的输入执行级联目标检测和姿态检测。
- **[自定义 Python 示例应用程序](https://docs.qualcomm.com/doc/80-70017-50SC/topic/customize-a-python-sample-application.html)**  

用户可以使用此过程中的说明开发自定义示例应用程序。

Last Published: Nov 11, 2025

[Previous Topic
视频合成](https://docs.qualcomm.com/bundle/publicresource/80-70017-50SC/topics/gst-weston-composition-example.md) [Next Topic
摄像头编码](https://docs.qualcomm.com/bundle/publicresource/80-70017-50SC/topics/camera-encode.md)