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

Problems with PyQt5 #4856

Closed
dguari1 opened this issue Sep 12, 2019 · 5 comments
Closed

Problems with PyQt5 #4856

dguari1 opened this issue Sep 12, 2019 · 5 comments
Labels

Comments

@dguari1
Copy link

dguari1 commented Sep 12, 2019

Required Info
Camera Model
Firmware Version
Operating System & Version {Win (8.1/10)
Kernel Version (Linux Only)
Platform PC
SDK Version
Language python
Segment

Issue Description

Hi

I'm aving problems using pyrealsense and PyQt5, the following code:

import sys
import pyrealsense2 as rs
from PyQt5.QtWidgets import QApplication

if __name__ == "__main__":
    app = QApplication(sys.argv)
    sys.exit(app.exec_())

produces this error:

QWindowsContext: OleInitialize() failed: "COM error 0xffffffff80010106 RPC_E_CHANGED_MODE (Unknown error 0x080010106)"

The pyqt application opens (when there is one in the code) but crashes when trying to do any action.
I tried the solution suggested here in this way

import warnings
warnings.simplefilter("ignore", UserWarning)
sys.coinit_flags = 2
import pyrealsense2 as rs

but it did't work in my case.

Thank you.

@RealSenseCustomerSupport
Copy link
Collaborator


Hi @dguari1,

Per my observation:
Although the error there, realsense camera can be still enabled to stream, right?

@RealSenseCustomerSupport
Copy link
Collaborator


The code I tried as follows:

**import** sys
**from** PyQt5.QtWidgets **import** QMainWindow , QApplication
**from** PyQt5.QtGui **import** QIcon
**import** pyrealsense2 **as** rs

**class** MainWidget(QMainWindow):
 **def** __init__(self,parent=**None**):
 super(MainWidget,self).__init__(parent)
 self.setWindowTitle(**"QMainWindow Example"**)
 self.resize(400, 200)
 self.status = self.statusBar()
 self.status.showMessage(**"Status"**,5000)

 **def** enableRSCamera(self):
 _# Configure depth and color streams_
 self.pipeline = rs.pipeline()
 self.config = rs.config()
 _# Start streaming_
 profile = self.pipeline.start()


**if** __name__ == **"__main__"**:
 app = QApplication(sys.argv)
 app.setWindowIcon(QIcon(**"./images/cartoon1.ico"**))
 main = MainWidget()
 print(**'Test...'**)
 main.show()
 main.enableRSCamera()
 print(**'Enabe RSCamera'**)
 sys.exit(app.exec_())

@dguari1
Copy link
Author

dguari1 commented Oct 10, 2019

Thx for replying.
The PyQt window does appear, but the program freezes immediately and crashes after a few seconds

@soarwing52
Copy link

soarwing52 commented Nov 1, 2019

Actually I created a PyQt5 application, with the same error notice, but mine runs just fine

one is to import it in the function in a multiprocess pool function
https://github.com/soarwing52/RealsensePython/blob/master/proccessor.py
this does not show any error because I suppose it's imported in the Pool

another is a camera control application, this imports in a thread
https://github.com/soarwing52/RealsensePython/tree/master/qtcam
this also has the error but everything works fine

@dguari1
Copy link
Author

dguari1 commented Nov 4, 2019

Importing pyrealsense locally solved the issue, thank you @soarwing52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants