I have a problem. My PyQt5 application is crashing as i resize,drag,maximize window. Here's thread:
class ImageCapturer(QtCore.QThread):
changeImages = QtCore.pyqtSignal(QtGui.QImage, QtGui.QImage)
lower_hsv = numpy.array([0,0,0])
upper_hsv = numpy.array([180,255,255])
cap = cv2.VideoCapture(1)
def run(self):
while True:
ret, frame = self.cap.read()
if ret:
original = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
#Some modification to frame
height, width, channel = original.shape
qt_img = QtGui.QImage(original, width, height, original.strides[0], QtGui.QImage.Format_RGB888)
height, width, channel = frame.shape
qt_img2 = QtGui.QImage(frame, width, height, res.strides[0], QtGui.QImage.Format_RGB888)
self.changeImages.emit(qt_img, qt_img2)
self.cap.release()
Also here is the function that is connected with signal :
@pyqtSlot(QtGui.QImage,QtGui.QImage)
def setImages(self, original, frame):
qt_pixmap = QtGui.QPixmap.fromImage(original)
self.original_image.setPixmap(qt_pixmap)
qt_pixmap = QtGui.QPixmap.fromImage(res)
self.processed_image.setPixmap(qt_pixmap)
Heres code of labels :
self.original_image = QtWidgets.QLabel()
self.original_image.setStyleSheet('border : 1px solid gray')
self.original_image.setMinimumHeight(240)
self.original_image.setMinimumWidth(320)
self.original_image.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
self.original_image.setScaledContents(True)
self.processed_image = QtWidgets.QLabel()
self.processed_image.setStyleSheet('border : 1px solid gray')
self.processed_image.setMinimumHeight(240)
self.processed_image.setMinimumWidth(320)
self.processed_image.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
self.processed_image.setScaledContents(True)
Heres how i created instance of that thread :
self.getImagesThread = ImageCapturer(self)
self.getImagesThread.changeImages.connect(self.setImages)
self.getImagesThread.setTerminationEnabled(True)
Also i created this based of : PyQt showing video stream from opencv
It doesn't happen all the time but it does at most of it. Sometimes i can resize maximize and all that.. Also I don't get any exception message or anything.. since i run it from IDLE once it happens it just shows ">>>" and that is basically it. Does anyone have a solution? I am new into this kind of stuff... Also it works normally when i use self.msleep(500)
lets say.. but whats the point of that when i want it to be smooth and i want it as video..