Issues with PyQt5 and multithreading #687
Replies: 1 comment
-
has QApplication been imported to the program (from PyQt5.QtWidgets import QApplicaton)? If it has been imported, have you tried to create the constructor and the exec_() method at the beginning and at the end of the program respectively, outside the if clause? I hope this helped tackle the issue |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am experiencing issues when using the Picamera2 library in combination with PyQt5 and multithreading. I have been working on an application that captures images from a Raspberry Pi camera module and displays them in a PyQt5 QLabel widget. In order to keep the UI responsive, I am using a QThread to handle the main loop for the camera.
However, when running the application, I am encountering the following warning and a subsequent segmentation fault:
To address this issue, we tried the following steps:
We ensured that QApplication was created in the main thread, and only the camera-related operations were moved to the QThread.
We moved the camera initialization and preview starting into the main thread, while keeping the main loop in the CameraThread.
Despite these attempts, the warning and segmentation fault persisted. Upon further investigation, it appears that the Picamera2 library itself might be triggering the warning due to the way it initializes the camera preview. The issue seems to be related to the interaction between the Picamera2 library and the PyQt5 event loop when using multithreading.
I kindly request your assistance in identifying the cause of the warning and the segmentation fault and in providing a solution or workaround for this problem. Below is a description of the relevant parts of the application:
The application consists of a CoreCamera class, which handles the camera-related operations (e.g., capturing images, processing plugins, and running the main loop). A CameraThread (subclass of QThread) is used to run the main loop without blocking the UI. The QLabel widget displays the captured images.
Here's the outline of the code:
Thank you in advance for your support. Your insights will be greatly appreciated in resolving this issue and helping us push the boundaries of this new library.
Best regards
Beta Was this translation helpful? Give feedback.
All reactions