# 创建您的 Qualcomm IM SDK 插件

本节介绍如何创建新的插件并将其编译为 Qualcomm Intelligent Multimedia Product SDK 的一部分。每个 ML 插件都被集成到一个独立的 BitBake 配方中。

## 更新 BitBake 文件以进行定制插件编译

1. 搭建环境。

cd $ESDK_ROOT
        Copy to clipboard

source environment-setup-armv8-2a-qcom-linux
        Copy to clipboard

SDK environment now set up; additionally you may now run devtool to perform development tasks.
        Run devtool --help for further details.
        [/local/mnt/workspace/Platform_eSDK_plus_QIM]$
        Copy to clipboard
2. 在 `$ESDK_ROOT/layers/meta-qcom-qim-product-sdk/recipes-gst/gstreamer/` 下添加新的 BitBake 文件

    例如，`$ESDK_ROOT/layers/meta-qcom-qim-product-sdk/recipes-gst/gstreamer/qcom-gstreamer1.0-plugins-oss-sample-mlvclassification.bb`

    1. 将现有插件（如 `$ESDK_ROOT/layers/meta-qcom-qim-product-sdk/recipes-gst/gstreamer/qcom-gstreamer1.0-plugins-oss-mlvclassification.bb`）中的内容复制至这个新文件中。
    2. 按如下所示更新以下变量。

SUMMARY = "My custom plugin for ML image categorization"
            SRC_URI = "file://gst-plugin-sample-mlvclassification"
            S = "${WORKDIR}/gst-plugin-sample-mlvclassification"
            Copy to clipboard

...
            inherit cmake pkgconfig
            
            SUMMARY = "My custom plugin for ML image categorization"**
            SECTION= "multimedia"
            
            LICENSE = "BSD-3-Clause-Clear"
            LIC_FILES_CHKSUM - "file://${COMMON_LICENSE_DIR}/${LICENSE};md5=7a43440b65lf4a472ca93716d01033a"
            
            # Dependencies.
            DEPENDS := "gstreamer1.0"
            DEPENDS += "gstreamer1.0-plugins-base"
            DEPENDS += "qcom-gstreamer1.0-plugins-oss-base" DEPENDS += "cairo"
            
            SRC_URI += "file://gst-plugin-sample-mlvclassification"
            S ="${WORKDIR}/gst-plugin-sample-mlvclassification"
            
            # Install directories.
            INSTALL_INCDIR := "${includedir}"
            ...
            Copy to clipboard
3. 在 `$ESDK_ROOT/layers/meta-qcom-qim-product-sdk/recipes-gst/gstreamer/` 中创建一个名为文件的目录。
4. 在 files 目录下创建 `gst-plugin-sample-mlvclassification` 目录并将 Qualcomm IM SDK 插件源代码复制到该目录中。

files/
        |
        +-- gst-plugin-sample-mlvclassification/
           |
           +-- CMakeLists.txt
           +-- config.h.in
           +-- mlvclassification.c
           +-- mlvclassification.h
           +-- modules/
              |
              +-- CMakeLists.txt
              +-- ml-vclassification-ocr.c
              +-- ml-vclassification-qfr.c
              +-- README
        Copy to clipboard

Note

这假设 `sample-mlvclassification` 插件的源代码可用。
5. 更新 `$ESDK_ROOT/layers/meta-qcom-qim-product-sdk/recipes-gst/packagegroups/packagegroup-qcom-gst.bb` 以在 `RDEPENDS` 中添加 `qcom-gstreamer1.0-plugins-oss-sample-mlvclassification`。

RDEPENDS:${PN}:qcom-custom-bsp = " \
           ${PN}-dependencies \
           ${PN}-basic \
           ...
           qcom-gstreamer1.0-plugins-oss-sample-mlvclassification \
        "
        Copy to clipboard
6. 更新 `$ESDK_ROOT/layers/meta-qcom-qim-product-sdk/classes/qimsdk-pkg.bbclass` 以添加 `qcom-gstreamer1.0-plugins-oss-sample-mlvclassification:do_package_write_ipk`。

GST_PLUGINS = " \
           gstd:do_package_write_ipk \
           gstreamer1.0:do_package_write_ipk \
           ...
           qcom-gstreamer1.0-plugins-oss-sample-mlvclassification:do_package_write_ipk \
        "
        Copy to clipboard
7. 下载 Qualcomm IM SDK 插件源代码。

cd $ESDK_ROOT
        Copy to clipboard

devtool modify qcom-gstreamer1.0-plugins-oss-sample-mlvclassification
        Copy to clipboard

其中 `qcom-gstreamer1.0-plugins-oss-sample-mlvclassification` 是下载插件源代码的 BitBake 配方。

NOTE: Starting bitbake server ...
        Loading cache: 100% |###################################################################################| Time 0:00:02
        Loaded 9814 entries from dependency cache.
        Parsing recipes: 100% |#################################################################################| Time 0:00:03
        Parsing of 6702 .bb files complete (6670 cached, 32 parsed). 9840 targets, 842 skipped, 0 masked, 0 errors.
        
        Summary: There were 0 WARNING messages.
        NOTE: Resolving any missing task queue dependencies
        Initialising tasks: 100% |##############################################################################| Time 0:00:08
        Sstate summary: Wanted 10 Local 0 Mirrors 0 Missed 10 Current 10 (0% match, 50% complete)
        NOTE: Executing Tasks
        NOTE: Tasks Summary: Attempted 93 tasks of which 90 didn't need to be rerun and all succeeded.
        INFO: Source tree extracted to /local/mnt/workspace/QIMSDK_ESDK_6490/workspace/sources/qcom-gstreamer1.0-plugins-oss-sample-mlvclassification
        INFO: Recipe qcom-gstreamer1.0-plugins-oss-sample-mlvclassification now set up to build from /local/mnt/workspace/QIMSDK_ESDK_6490/workspace/sources/qcom-gstreamer1.0-plugins-oss-sample-mlvclassification
        Copy to clipboard
8. 定制完成后，使用以下命令重新编译插件。

devtool build qcom-gstreamer1.0-plugins-oss-sample-mlvclassification
        Copy to clipboard

NOTE: Starting bitbake server ...
        Loading cache: 100% |                                      | ETA -:--:--
        Loaded 0 entries from dependency cache.
        ...
        Copy to clipboard
9. 生成插件安装程序 (.ipk) 以便在设备上安装插件。

devtool package qcom-gstreamer1.0-plugins-oss-sample-mlvclassification
        Copy to clipboard

NOTE: Starting bitbake server ...
        Loading cache: 100% |###################################################################| ETA 0:00:14
        Loaded 9812 entries from dependency cache.
        Parsing recipes: 100% |#################################################################################| Time 0:00:03
        Parsing of 6702 .bb files complete (6674 cached, 28 parsed). 9840 targets, 842 skipped, 0 masked, 0 errors.
        NOTE: Resolving any missing task queue dependencies
        Initialising tasks: 100% |##############################################################################| Time 0:00:10
        Checking sstate mirror object availability: 100% |######################################################| Time 0:00:00
        Sstate summary: Wanted 262 Local 0 Mirrors 0 Missed 262 Current 259 (0% match, 49% complete)
        NOTE: Executing Tasks
        NOTE: Tasks Summary: Attempted 1847 tasks of which 1847 didn't need to be rerun and all succeeded.
        
        Summary: There were 0 WARNING messages.
        INFO: Your packages are in /local/mnt/workspace/QIMSDK_ESDK_6490/tmp/deploy/ipk
        Copy to clipboard
10. 确认可安装软件包已位于以下路径。

ls $ESDK_ROOT/tmp/deploy/ipk/armv8-2a | grep qcom-gstreamer1.0-plugins-oss-sample-mlvclassification
        Copy to clipboard

qcom-gstreamer1.0-plugins-oss-sample-mlvclassification_1.0-r0_armv8-2a.ipk
        qcom-gstreamer1.0-plugins-oss-sample-mlvclassification_dbg_1.0-r0_armv8-2a.ipk
        qcom-gstreamer1.0-plugins-oss-sample-mlvclassification_dev_1.0-r0_armv8-2a.ipk
        qcom-gstreamer1.0-plugins-oss-sample-mlvclassification_src_1.0-r0_armv8-2a.ipk
        [/local/mnt/workspace/Platform_eSDK_plus_QIM]$
        Copy to clipboard
11. 按照[使用 SSH 登录](https://docs.qualcomm.com/bundle/publicresource/topics/80-70018-254/how_to.html#use-ssh)中提供的步骤，建立与设备的 SSH 连接。

    连接成功后，即可通过为 RB3 Gen 2 设备配置的 IP 地址访问该设备。
12. 将 `qcom-gstreamer1.0-plugins-oss-sample-mlvclassification_1.0-r0_armv8-2a.ipk` 复制到 RB3 Gen 2 设备以安装编译的参考应用。
13. 通过 SSH shell 连接到设备：

ssh root@<IP addr of the target device>
        Copy to clipboard

Note

如果出现提示，请输入 `oelinux123` 作为 SSH shell 的密码。
14. 在目标设备上运行以下命令。

mount -o remount,rw /
        exit
        Copy to clipboard
15. 在主机上运行以下命令：

cd $ESDK_ROOT/tmp/deploy/ipk/armv8-2a/
        Copy to clipboard

scp qcom-gstreamer1.0-plugins-oss-sample-mlvclassification_1.0-r0_armv8-2a.ipk root@< IP addr of the target device>:/opt/
        Copy to clipboard
16. 通过 SSH shell 连接到设备：

ssh root@<IP addr of the target device>
        Copy to clipboard
17. 在目标设备上运行以下命令：

opkg --force-depends --force-reinstall --force-overwrite install /opt/qcom-gstreamer1.0-plugins-oss-sample-mlvclassification_1.0-r0_armv8-2a.ipk
        Copy to clipboard

新插件现已安装，可供需要该插件的应用程序使用。

Last Published: Feb 06, 2026

[Previous Topic
编译并安装 Qualcomm IM SDK 插件](https://docs.qualcomm.com/bundle/publicresource/80-70018-51SC/topics/compile-install-imsdk-plugins.md) [Next Topic
常见故障处理](https://docs.qualcomm.com/bundle/publicresource/80-70018-51SC/topics/troubleshooting.md)