高通 IM SDK 开发全景洞察:从基础搭建到高级定制的技术跨越

高通 Ubuntu 中的多媒体和 AI 功能使用参考应用程序附带的 高通 IM SDK 和 GStreamer 插件。请按照以下步骤安装 QIM SDK 并运行内置的参考应用程序。

先决条件:像 RB3Gen2 这样的高通开发套件。

  1. 按照说明使用最新软件版本对高通开发套件进行编程。
  2. 重新启动设备并登录控制台
  3. 设置Wi-Fi 并刷新包管理器
    通过将此不受信任的 PPA 中不受支持的软件包添加ppa:ubuntu-qcom-iot/qcom-ppa到系统的软件源中来更新您的系统。
    sudo add-apt-repository ppa:ubuntu-qcom-iot/qcom-ppa
    sudo apt update
  4. 更新sources.list文件以包含 PPA。
    1. sources.list在 Vim 中 打开。
      sudo vim /etc/apt/sources.list
    2. 添加以下行。
      deb-src https://ppa.launchpadcontent.net/ubuntu-qcom-iot/qcom-ppa/ubuntu jammy main
  5. 安装 高通 IM SDK 插件和参考应用程序。
    sudo apt update -y && sudo apt install -y weston-qcom
    sudo apt install -y camx-kt gstreamer1.0-tools gstreamer1.0-plugins-qcom-tools gstreamer1.0-plugins-qcom 
    sudo apt install -y libsnpe1 libqnn1
    sudo apt install -y gstreamer1.0-qcom-sample-apps
  6. 以 sudo 用户身份设置 DISPLAY 环境。
    sudo -i
    export XDG_RUNTIME_DIR=/run/user/$(id -u ubuntu)/ && export WAYLAND_DISPLAY=wayland-1
  7. 运行默认参考应用程序

编译参考应用程序

高通 Development Kit 上下载 高通 IM SDK 和参考应用程序源代码,并使用 cmake 等标准开发工具进行编译。

要下载源代码并编译示例应用程序,请在 高通 开发套件上运行以下命令。

  1. 建立依赖关系。
    sudo apt build-dep gstreamer1.0-qcom-sample-apps 
  2. 将目录更改为主文件夹。

    cd /home/ubuntu
  3. 寻找参考应用程序。
    apt source gstreamer1.0-qcom-sample-apps
  4. 导航到参考应用程序目录。
    cd gst-plugins-qti-oss-2.0.0.r1/gst-sample-apps/
  5. 制作并导航至构建目录。
    mkdir build; cd build 
  6. 运行 cmake。
    cmake \
    -DGST_VERSION_REQUIRED=1.20.1 \
    -DSYSROOT_INCDIR=/usr/include \
    -DSYSROOT_LIBDIR=/usr/lib \
    -DGST_PLUGINS_QTI_OSS_INSTALL_BINDIR=/usr/bin \
    -DENABLE_CAMERA=TRUE \
    -DENABLE_VIDEO_ENCODE=TRUE \
    -DENABLE_VIDEO_DECODE=TRUE \
    -DENABLE_DISPLAY=TRUE \
    -DENABLE_ML=TRUE \
    -DENABLE_AUDIO=TRUE \
    -DCAMERA_SERVICE=LECAM \
    ..
  7. 编译参考应用程序。
    make
    如果成功,编译的参考应用程序可执行文件将出现在源代码的文件夹中。
  8. 运行以下命令来安装程序。
    sudo make install

更新 高通 IM SDK 插件

mlvsegmentation本节以该插件为例,介绍如何更新 高通 IM SDK 插件 。

以下步骤更新mlvsegmentation插件。

  1. 建立依赖关系。
    sudo apt build-dep gstreamer1.0-qcom-sample-apps
  2. 寻找参考应用程序。
    apt source gstreamer1.0-qcom-sample-apps
  3. 导航到 mlvsegmentation 插件目录。
    cd gst-plugins-qti-oss-2.0.0.r1/gst-plugin-mlvsegmentation
  4. 在CMakeList.txtadd_subdirectory 中的(最后一行) 之前立即插入以下几行。
    include_directories(../gst-plugin-base)
    include_directories(../gst-ml-metadata)
  5. 制作并导航至构建 目录。
    mkdir build; cd build
  6. 运行 cmake。
    cmake \
    -DGST_VERSION_REQUIRED=1.20.1 \
    -DSYSROOT_INCDIR=/usr/include \
    -DSYSROOT_LIBDIR=/usr/lib \
    -DGST_PLUGINS_QTI_OSS_VERSION=2.0.0 \
    -DGST_PLUGINS_QTI_OSS_LICENSE=BSD \
    -DGST_PLUGINS_QTI_OSS_VERSION=2.0.0 \
    -DGST_PLUGINS_QTI_OSS_PACKAGE=gstreamer1.0-plugins-qcom-oss \
    -DGST_PLUGINS_QTI_OSS_SUMMARY="Qualcomm open-source GStreamer Plug-ins" \
    -DGST_PLUGINS_QTI_OSS_ORIGIN="http://www.qualcomm.com" \
    ..
  7. 运行 make 来编译更新的插件。
    cd ..; make
    如果成功,编译后的应用程序将加载更新的插件。
  8. 运行以下命令安装插件。
    sudo make install

开发您的第一个应用程序

本节介绍如何创建您的第一个应用程序并将其安装到设备上。我们将创建一个新的应用程序,使用 make 进行编译,然后在目标设备上运行它。

使用 Makefile 进行开发

  1. 从 GitHub 下载 Hello-QIM 示例应用程序。
    git clone https://github.com/quic/sample-apps-for-qualcomm-linux
  2. 导航到 Hello-QIM 应用程序。
    cd sample-apps-for-qualcomm-linux/Hello-QIM
  3. 重命名main.ccgst-appsink.cc或复制 main.cc到 gst-appsink.cc
    cp main.cc gst-appsink.cc
  4. 根据您的 Ubuntu 环境修改 make 文件。
    CC = aarch64-linux-gnu-g++
    CFLAGS = -Wall -g $(shell pkg-config --cflags gstreamer-1.0)
    LDFLAGS = $(shell pkg-config --libs gstreamer-1.0)
    
    all: gst-appsink
    
    gst-appsink: gst-appsink.o
        $(CC) -o $@ $^ $(LDFLAGS)
    
    gst-appsink.o: gst-appsink.cc
        $(CC) $(CFLAGS) -c $<
    
    clean:
        rm -f gst-appsink gst-appsink.o
  5. 编译应用程序。
    make
    编译成功后,gst-appsink生成应用程序二进制文件()。
  6. 运行该应用程序。
    ../../HelloQIM/sample-apps-for-qualcomm-linux/Hello-QIM# chmod 777 gst-appsink
    ../../HelloQIM/sample-apps-for-qualcomm-linux/Hello-QIM# ./gst-appsink -w 1280 -h 720
  7. 应用程序执行后,将显示以下消息。
    Hello-QIM: Success creating pipeline and received camera frame.

创建您自己的应用程序

本节介绍如何创建您自己的应用程序并将其安装到设备上。为简单起见,我们将复制一个现有应用程序,并将其编译为新应用程序。

高通Development Kit 上下载高通 IM SDK 和参考应用程序源代码,并使用 cmake 等标准开发工具进行编译。

要下载源代码并编译示例应用程序,请在 高通 开发套件上运行以下命令。

  1. 建立依赖关系。
    sudo apt build-dep gstreamer1.0-qcom-sample-apps
  2. 提供参考应用程序。
    apt source gstreamer1.0-qcom-sample-apps
  3. 导航到参考应用程序目录。
    cd gst-plugins-qti-oss-2.0.0.r1/gst-sample-apps/
  4. 使用新名称复制一份参考应用程序。

    例如:

    cp -rf gst-ai-classification gst-ai-classification-example
    cd gst-ai-classification-example
  5. 更改CMakeLists.txt文件中的可执行文件名称 。
    set(GST_EXAMPLE_BIN gst-ai-classification-example)
    
    add_executable(${GST_EXAMPLE_BIN}
      main.cc
    )
    
    target_include_directories(${GST_EXAMPLE_BIN} PRIVATE
      ${GST_INCLUDE_DIRS}
      ${CMAKE_SOURCE_DIR}
    )
    
    target_link_libraries(${GST_EXAMPLE_BIN} PRIVATE
      ${GST_LIBRARIES}
    )
    
    install
      TARGETS ${GST_EXAMPLE_BIN}
      RUNTIME DESTINATION ${GST_PLUGINS_QTI_OSS_INSTALL_BINDIR}
      PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
                  GROUP_EXECUTE GROUP_READ
                  WORLD_EXECUTE WORLD_READ
    )
  6. 导航到参考应用程序目录。
    cd gst-plugins-qti-oss-2.0.0.r1/gst-sample-apps/
  7. 将新的子目录添加到 CMakeLists.txt
    if (ENABLE_ML AND ENABLE_CAMERA AND ENABLE_DISPLAY AND ENABLE_VIDEO_ENCODE
      add_subdirectory(gst-ai-classification)
    +  add_subdirectory(gst-ai-classification-example)
      add_subdirectory(gst-ai-object-detection)
      add_subdirectory(gst-ai-pose-detection)
      add_subdirectory(gst-ai-segmentation)
      add_subdirectory(gst-ai-parallel-inference)
      add_subdirectory(gst-ai-multi-input-output-object-detection)
      add_subdirectory(gst-ai-monodepth)
      add_subdirectory(gst-ai-daisychain-detection-classification)
    endif () # ENABLE_CAMERA AND ENABLE_DISPLAY AND ENABLE_VIDEO_ENCODE
  8. 创建并导航到build 目录。
    mkdir build; cd build
  9. 运行 cmake。
    cmake \
      -DGST_VERSION_REQUIRED=1.20.1 \
      -DSYSROOT_INCDIR=/usr/include \
      -DSYSROOT_LIBDIR=/usr/lib \
      -DGST_PLUGINS_QTI_OSS_INSTALL_BINDIR=/usr/bin \
      -DENABLE_CAMERA=TRUE \ 
      -DENABLE_VIDEO_ENCODE=TRUE \
      -DENABLE_VIDEO_DECODE=TRUE \
      -DENABLE_DISPLAY=TRUE \
      -DENABLE_ML=TRUE \
      -DENABLE_AUDIO=TRUE \
      -DCAMERA_SERVICE=LECAM \
      ..
  10. 编译参考应用程序。
    make
    编译并生成的示例应用程序位于以下路径/root/gst-plugins-qti-oss-2.0.0.r1/gst-sample-apps/build/gst-ai-classification-example
    ls -al /root/gst-plugins-qti-oss-2.0.0.r1/gst-sample-apps/build/gst-ai-classification-example
    total 64
    jrwxr-xr-x  3 root root  4096 Nov 18 14:06 .
    jrwxr-xr-x 33 root root  4096 Nov 18 14:06 ..
    jrwxr-xr-x  3 root root  4096 Nov 18 14:06 CMakeFiles
    -rw-r--r--  1 root root  8879 Nov 18 14:06 Makefile
    -rw-r--r--  1 root root  2662 Nov 18 14:06 cmake_install.cmake
    -rwxr-xr-x  1 root root 33624 Nov 18 14:06 gst-ai-classification-example 

创建新插件

本节介绍如何创建新插件并将其编译为高通IM SDK 的一部分。

您必须在 高通开发套件上下载 高通 IM SDK 和参考应用程序源代码,并使用 cmake 等标准开发工具进行编译。

以下步骤将指导您创建新的插件。

  1. 导航到gstreamer源目录
    sudo -i
    cd /root/gst-plugins-qti-oss-2.0.0.r1
  2. 在 处创建一个新插件/root/gst-plugins-qti-oss-2.0.0.r1

    例如:

    mkdir /root/gst-plugins-qti-oss-2.0.0.r1/gst-plugin-sample-mlvclassification
  3. 将现有插件的内容复制mlvclassification到 步骤 2 中创建的gst-plugin-sample-mlvclassification目录。
    注意:确保新的源代码可用于 sample-mlvclassification 插件。
  4. 将新gst-plugin-sample-mlvclassification插件添加到 CMakeList.txt 文件中。
    cd /root/gst-plugins-qti-oss-2.0.0.r1
    project(gst-plugins-qti-oss)
    include_directories(${SYSROOT_INCDIR}/log)
    include_directories(gst-sample-apps)
    . . . 
    add_subdirectory(gst-plugin-mldemux)
    add_subdirectory(gst-plugin-mlvconverter)
    add_subdirectory(gst-plugin-mlvclassification)
    + add_subdirectory(gst-plugin-sample-mlvclassification)
    add_subdirectory(gst-plugin-mlvsuperresolution)
    . . . 
  5. 创建并导航到build 目录
    mkdir build; cd build
  6. 运行 cmake。
    cmake \
      -DGST_VERSION_REQUIRED=1.20.1 \
      -DSYSROOT_INCDIR=/usr/include \
      -DSYSROOT_LIBDIR=/usr/lib \
      -DGST_PLUGINS_QTI_OSS_VERSION=2.0.0 \
      ..
  7. 运行 make 来编译更新的插件。
    make
    如果成功,编译后的参考插件将出现在源代码的文件夹中。
    root@ubuntu:~/gst-plugins-qti-oss-2.0.0.r1/build/gst-plugin-sample-mlvclassification# ls
    CMakeFiles  Makefile  cmake_install.cmake  config.h  libgstqtimlvclassificationsample.so  modules

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值