请选择 进入手机版 | 继续访问电脑版
1.1


已有onnx,rknn模型,想用qt实现基于yolov8做摄像头实时检测,部署到板端buildroot文件系统或者desktop文件系统皆可


1.2
elf2开发板


2.1
因为技术有限无法做到基于qt实现目标功能,于是计划用pyqt5代替,在电脑端已经可以实现预期功能,模型和程序均可用,但是想部署到elf2上出现问题。因为buildroot文件系统没有opencv相关库文件,于是在desktop文件系统尝试。已经成功导入所需各种库文件,模型导入也成功,但是生成图像化界面时警告报错:
qt.qpa.xcb:could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though itwas found.
This application failed to start because no Qt platform plugin could be initialized.Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal,minimalegl, offscreenvnc,wayland-egL,wayland,wayland-xcomposite-egl,wayland-xcomposite-glx, xcb


2.2
风哥建议执行环境变量export DISPLAY=0.0,并在ubuntu板端终端运行后扔无法运行
qt.qpa.xcb:could not connect to display 0.0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in ""even though itwas found.
This application failed to start because no Qt platform plugin could be initialized, Reinstalling the application may fix this problem.Available platform plugins are:eglfs, linuxfb, minimal,minimalegl, offscreenultrevnc,wayland-egl,wayland,wayland-xcomposite-egl,wayland-xcomposite-glx,xcbAborted

发表于 2025-6-16 16:27:01 | 显示全部楼层
沙发
参考下面步骤试试,我这边测试着没有问题

一、网络设置
root@elf2-desktop:/home/elf# nmcli con mod 'Wired connection 1' ipv4.method manual ipv4.addresses 10.10.19.45/24 ipv4.gateway 10.10.19.254 ipv4.dns 8.8.8.8 connection.autoconnect yes
root@elf2-desktop:/home/elf# nmcli con up 'Wired connection 1'
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)

二、安装PYQT5
elf@elf2-desktop:~$ sudo apt install python3-pyqt5 pyqt5-dev-tools

三、测试例程
import sys
from PyQt5.QtWidgets import QApplication, QWidget

if __name__ == '__main__':
    app = QApplication(sys.argv)

    window = QWidget()
    window.setWindowTitle('PyQt5 Test')
    window.setGeometry(100, 100, 300, 200)
    window.show()

    sys.exit(app.exec_())

四、执行环境变量,测试应用
elf@elf2-desktop:~$ export DISPLAY=:0.0
elf@elf2-desktop:~$ python3 c.py
运行效果如下:
Screenshot from 2025-06-16 16-19-19.png


    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Powered by Discuz! X3.5  © 2001-2013 Comsenz Inc.