Pyqtgraph Imageview Freezes When Multithreaded
I have multiple cameras that are hooked up wirelessly via wifi and I'm trying to stream the data to a client, which displays the streams on a GUI. My issue is that the pyqtgraph Im
Solution 1:
You should not update the GUI from another thread since Qt forbids it . So you must use signals to transmit the information.
classWindowUpdater(QThread):
imageChanged = pyqtSignal(np.ndarray)
stop_q = Queue()
def__init__(self, cam_q: Queue, **kwargs):
super().__init__(**kwargs)
self.q = cam_q
defrun(self) -> None:
while self.stop_q.empty():
try:
timg = self.q.get_nowait()
graph_lock.acquire(True)
self.imageChanged.emit(timg.frame)
graph_lock.release()
except Empty:
time.sleep(0.1)
# ...
for i, h in enumerate(hosts):
img = pg.ImageView(window)
grid.addWidget(img, i, 0)
img_item = pg.ImageItem()
img.addItem(img_item)
thread = WindowUpdater(img_queue)
thread.imageChanged.connect(img.setImage)
threads.append(thread)
# ...
Post a Comment for "Pyqtgraph Imageview Freezes When Multithreaded"