高通 Ubuntu 中的多媒体和 AI 功能使用参考应用程序附带的 高通 IM SDK 和 GStreamer 插件。请按照以下步骤安装 QIM SDK 并运行内置的参考应用程序。
先决条件:像 RB3Gen2 这样的高通开发套件。
- 按照说明使用最新软件版本对高通开发套件进行编程。
- 重新启动设备并登录控制台。
- 设置Wi-Fi 并刷新包管理器。
通过将此不受信任的 PPA 中不受支持的软件包添加
ppa:ubuntu-qcom-iot/qcom-ppa
到系统的软件源中来更新您的系统。sudo add-apt-repository ppa:ubuntu-qcom-iot/qcom-ppa
sudo apt update
- 更新
sources.list
文件以包含 PPA。sources.list
在 Vim 中 打开。sudo vim /etc/apt/sources.list
- 添加以下行。
deb-src https://ppa.launchpadcontent.net/ubuntu-qcom-iot/qcom-ppa/ubuntu jammy main
- 安装 高通 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
- 以 sudo 用户身份设置 DISPLAY 环境。
sudo -i
export XDG_RUNTIME_DIR=/run/user/$(id -u ubuntu)/ && export WAYLAND_DISPLAY=wayland-1
- 运行默认参考应用程序。
编译参考应用程序
在 高通 Development Kit 上下载 高通 IM SDK 和参考应用程序源代码,并使用 cmake 等标准开发工具进行编译。
要下载源代码并编译示例应用程序,请在 高通 开发套件上运行以下命令。
- 建立依赖关系。
sudo apt build-dep gstreamer1.0-qcom-sample-apps
-
将目录更改为主文件夹。
cd /home/ubuntu
- 寻找参考应用程序。
apt source gstreamer1.0-qcom-sample-apps
- 导航到参考应用程序目录。
cd gst-plugins-qti-oss-2.0.0.r1/gst-sample-apps/
- 制作并导航至构建目录。
mkdir build; cd build
- 运行 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 \ ..
- 编译参考应用程序。
如果成功,编译的参考应用程序可执行文件将出现在源代码的文件夹中。make
- 运行以下命令来安装程序。
sudo make install
更新 高通 IM SDK 插件
mlvsegmentation
本节以该插件为例,介绍如何更新 高通 IM SDK 插件 。
以下步骤更新mlvsegmentation
插件。
- 建立依赖关系。
sudo apt build-dep gstreamer1.0-qcom-sample-apps
- 寻找参考应用程序。
apt source gstreamer1.0-qcom-sample-apps
- 导航到 mlvsegmentation 插件目录。
cd gst-plugins-qti-oss-2.0.0.r1/gst-plugin-mlvsegmentation
- 在CMakeList.txt
add_subdirectory
中的(最后一行) 之前立即插入以下几行。include_directories(../gst-plugin-base) include_directories(../gst-ml-metadata)
- 制作并导航至构建 目录。
mkdir build; cd build
- 运行 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" \ ..
- 运行 make 来编译更新的插件。
如果成功,编译后的应用程序将加载更新的插件。cd ..; make
- 运行以下命令安装插件。
sudo make install
开发您的第一个应用程序
本节介绍如何创建您的第一个应用程序并将其安装到设备上。我们将创建一个新的应用程序,使用 make 进行编译,然后在目标设备上运行它。
使用 Makefile 进行开发
- 从 GitHub 下载 Hello-QIM 示例应用程序。
git clone https://github.com/quic/sample-apps-for-qualcomm-linux
- 导航到 Hello-QIM 应用程序。
cd sample-apps-for-qualcomm-linux/Hello-QIM
- 重命名
main.cc
为gst-appsink.cc
或复制main.cc
到gst-appsink.cc
。cp main.cc gst-appsink.cc
- 根据您的 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
- 编译应用程序。
编译成功后,make
gst-appsink
生成应用程序二进制文件()。 - 运行该应用程序。
../../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
- 应用程序执行后,将显示以下消息。
Hello-QIM: Success creating pipeline and received camera frame.
创建您自己的应用程序
本节介绍如何创建您自己的应用程序并将其安装到设备上。为简单起见,我们将复制一个现有应用程序,并将其编译为新应用程序。
在高通Development Kit 上下载高通 IM SDK 和参考应用程序源代码,并使用 cmake 等标准开发工具进行编译。
要下载源代码并编译示例应用程序,请在 高通 开发套件上运行以下命令。
- 建立依赖关系。
sudo apt build-dep gstreamer1.0-qcom-sample-apps
- 提供参考应用程序。
apt source gstreamer1.0-qcom-sample-apps
- 导航到参考应用程序目录。
cd gst-plugins-qti-oss-2.0.0.r1/gst-sample-apps/
- 使用新名称复制一份参考应用程序。
例如:
cp -rf gst-ai-classification gst-ai-classification-example
cd gst-ai-classification-example
- 更改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 )
- 导航到参考应用程序目录。
cd gst-plugins-qti-oss-2.0.0.r1/gst-sample-apps/
- 将新的子目录添加到 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
- 创建并导航到
build
目录。mkdir build; cd build
- 运行 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 \ ..
- 编译参考应用程序。
编译并生成的示例应用程序位于以下路径/root/gst-plugins-qti-oss-2.0.0.r1/gst-sample-apps/build/gst-ai-classification-examplemake
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 等标准开发工具进行编译。
以下步骤将指导您创建新的插件。
- 导航到
gstreamer
源目录sudo -i
cd /root/gst-plugins-qti-oss-2.0.0.r1
- 在 处创建一个新插件
/root/gst-plugins-qti-oss-2.0.0.r1
。例如:
mkdir /root/gst-plugins-qti-oss-2.0.0.r1/gst-plugin-sample-mlvclassification
- 将现有插件的内容复制
mlvclassification
到 步骤 2 中创建的gst-plugin-sample-mlvclassification目录。注意:确保新的源代码可用于 sample-mlvclassification 插件。 - 将新
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) . . .
- 创建并导航到
build
目录mkdir build; cd build
- 运行 cmake。
cmake \ -DGST_VERSION_REQUIRED=1.20.1 \ -DSYSROOT_INCDIR=/usr/include \ -DSYSROOT_LIBDIR=/usr/lib \ -DGST_PLUGINS_QTI_OSS_VERSION=2.0.0 \ ..
- 运行 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