Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOW-TO] Could not load the Qt platform plugin "xcb" in "" even though it was found. #789

Closed
baqwas opened this issue Sep 5, 2023 · 5 comments

Comments

@baqwas
Copy link

baqwas commented Sep 5, 2023

Please only ask one question per issue!

Describe what it is that you want to accomplish
The error message contains the string:
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Which application should be re-installed?

Describe alternatives you've considered
Running the following script from The Picamera2 Library page 7 documentation:

from picamera2 import Picamera2, Preview
import time
picam2 = Picamera2()
camera_config = picam2.create_preview_configuration()
picam2.configure(camera_config)
picam2.start_preview(Preview.QTGL)
picam2.start()
time.sleep(2)
picam2.capture_file("test.jpg")

Preview.DRM had more errors.

Additional context
Add any other context or screenshots about the request here.

$ sudo apt install python3-v4l2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-v4l2 is already the newest version (0.3.2-1).
python3-v4l2 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

There is no pip3 installed v4l2 package as shown below:

user@raspberrypi:~/.local/lib/python3.9/site-packages $ ls
ljpegCompress.cpython-39-arm-linux-gnueabihf.so  piexif
numpy                                            piexif-1.1.3.dist-info
numpy-1.23.1.dist-info                           __pycache__
OpenGL                                           PyOpenGL-3.1.6.dist-info
pidng                                            simplejpeg
pidng-4.0.9.dist-info                            simplejpeg-1.6.4.dist-info
$ uname -a
Linux raspberrypi 6.1.21+ #1642 Mon Apr  3 17:19:14 BST 2023 armv6l GNU/Linux
$
OS: Raspbian GNU/Linux 11 (bullseye) armv6l
Host: Raspberry Pi Model B Plus Rev 1.2

Glamor is enabled; required to run libcamera-hello successfully.

With Preview.QTGL the following output is displayed:

$ python3 ./camera_test.py
[11:36:33.147519858] [31060]  INFO Camera camera_manager.cpp:297 libcamera v0.0.5+83-bde9b04f
[11:36:33.370927893] [31061]  INFO RPI vc4.cpp:437 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media3 and ISP device /dev/media0
[11:36:33.373569846] [31061]  INFO RPI pipeline_base.cpp:1101 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
[11:36:33.472279094] [31060]  INFO Camera camera.cpp:1033 configuring streams: (0) 640x480-XBGR8888 (1) 640x480-SGBRG10_CSI2P
[11:36:33.476899012] [31061]  INFO RPI vc4.cpp:565 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 640x480-SGBRG10_1X10 - Selected unicam format: 640x480-pGAA
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was 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, offscreen, vnc, xcb.

Aborted

Thanks!

@davidplowman
Copy link
Collaborator

Is your Pi connected directly to a display using an HDMI cable? Are you logged directly in to your Pi (through an attached keyboard), or are you connected via ssh or VNC? Could you test if libcamera-hello and libcamera-hello --qt-preview work? Thanks!

@baqwas
Copy link
Author

baqwas commented Sep 9, 2023

Sorry for the belated response.

Is your Pi connected directly to a display using an HDMI cable?
No. It is in server closet and access is primarily headless. If you insist (for support purposes), I'll have to bring it downstairs and wire it up temporarily. FWIW, the same hardware and picamera2 (beta releases) worked several months ago. Somewhere along the way the Bullseye update/upgrade that I do unattended on a weekly basis caused this issue, I believe. Sorry, cannot pinpoint the date.

Are you logged directly in to your Pi (through an attached keyboard), or are you connected via ssh or VNC?
Headless relying mostly on SSH and VNC.

Could you test if libcamera-hello and libcamera-hello --qt-preview work?
libcamera-hello
SSH:
$ libcamera-hello
Preview window unavailable
[111:37:02.050104693] [13411] INFO Camera camera_manager.cpp:299 libcamera v0.0.4+23-06bbff9c
[111:37:02.276276710] [13412] INFO RPI raspberrypi.cpp:1486 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media3 and ISP device /dev/media0
[111:37:02.283435679] [13411] INFO Camera camera.cpp:1028 configuring streams: (0) 1296x972-YUV420
[111:37:02.287963659] [13412] INFO RPI raspberrypi.cpp:861 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA
#0 (0.00 fps) exp 33222.00 ag 8.00 dg 1.00
#1 (30.01 fps) exp 33222.00 ag 8.00 dg 1.00

This is not an issue; understand just a little bit about what is going on here.

VNC:
chowkidar@raspbari1:~/projects $ libcamera-hello
Preview window unavailable
[111:40:01.968939526] [14134] INFO Camera camera_manager.cpp:299 libcamera v0.0.4+23-06bbff9c
[111:40:02.703916260] [14141] INFO RPI raspberrypi.cpp:1486 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media3 and ISP device /dev/media0
[111:40:02.725973162] [14134] INFO Camera camera.cpp:1028 configuring streams: (0) 1296x972-YUV420
[111:40:02.752485044] [14141] INFO RPI raspberrypi.cpp:861 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA
#0 (0.00 fps) exp 33222.00 ag 8.00 dg 1.00
#1 (10.00 fps) exp 33222.00 ag 8.00 dg 1.00

Not sure why the preview window did not launch.

libcamera-hello --qt-preview
SSH: (again not expecting to be able to view any window so I don't pay attention to this mode but of course would like to use the -o option which I cannot presently)
$ libcamera-hello --qt-preview
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was 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, offscreen, vnc, xcb.

Aborted

VNC:
chowkidar@raspbari1:~/projects $ libcamera-hello --qt-preview
Made QT preview window
[111:40:37.308357203] [14189] INFO Camera camera_manager.cpp:299 libcamera v0.0.4+23-06bbff9c
qt.qpa.xcb: QXcbConnection: XCB error: 148 (Unknown), sequence: 191, resource id: 0, major code: 140 (Unknown), minor code: 20
[111:40:38.186930284] [14223] INFO RPI raspberrypi.cpp:1486 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media3 and ISP device /dev/media0
[111:40:38.225136114] [14189] INFO Camera camera.cpp:1028 configuring streams: (0) 1296x972-YUV420
[111:40:38.244903026] [14223] INFO RPI raspberrypi.cpp:861 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA

In the last scenario, an untitled window appears momentarily and then disappears.

Again, FWIW, I am using libcamera utilities successfully on other diverse RPi boards. This specific board is an older one (SDcard not microSD! Raspberry Pi Model B Plus Rev 1.2). If you feel that I should simply re-image it with the latest Raspberry Pi OS and try again, I will gladly do that. I am simply hoping for a quick fix since the computer does infrastructure support and I'd prefer some update/upgrade fix rather than re-install other 3rd party packages.

Thanks again for all your support. Sincerely appreciate it.

Regards.

@tvoverbeek
Copy link
Contributor

You wrote:
This specific board is an older one (SDcard not microSD! Raspberry Pi Model B Plus Rev 1.2).
This is the first model with 40-pin GPIO header from 2014.
It has only 512 MB of memory. So you might be running out of memory.
Picamera2 and libcamera use a lot of memory for image buffers.

@davidplowman
Copy link
Collaborator

Generally I find that managing Qt and OpenCV versions (among other packages) is a bit tricky, and if you ever install the "wrong" version of something it can be quite difficult to know how to recover. If you do have a spare SD card and are able to, it's probably worth trying a fresh install. If you use the full version of the OS, your original script should "just work".

The point about using an older device is a good one. I believe a fresh install should work, however, rendering through to the display using Qt and X Windows is likely to be pretty painful, I'd have thought, to the point of barely usable. If you can, you might want to consider the Lite OS and the DRM preview.

@baqwas
Copy link
Author

baqwas commented Sep 11, 2023

Thanks, @davidplowman. Will accept the advice and re-image. Naturally, I'll get picamera2 library to work first before installing all the other stuff most of which are scripted anyway.

I have several RPis and Picamera2 is working (and some supporting OpenCV too). My purpose in logging the issue was two-fold:

  • Understand the dimension of backwards compatibility with Raspberry Pi OS (not Raspbian)
  • Continue to use the hardware for the simple task of keeping an eye on who is working in the server closet (Zero 2W are impossible to find these days)

Regards.

@baqwas baqwas closed this as completed Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants