Python qt5 QLabel setPixmap display Problem
Solved
General and Desktop
-
Hi to all,
I have to try display a rgb image (1030x360x3) inside Qlabel object of QT5 with python3.
The image type is numpy array. And, I tried make display a frame with following code parts.
disp_frame = QtGui.QImage(frame.data, 1030, 360, QtGui.QImage.Format_RGB888).rgbSwapped() self.qt_label.setPixmap(QtGui.QPixmap.fromImage(disp_frame))
- The problem is displayed image that showed like as following (above) picture. The above image is displayed in Qtlabel and the below one is opencv showed image (as desired). Is there any way to correctly fix the image.
- Another example image displayed as following picture.
Designed Qlabel Parameters are:
-
@msyasak See https://stackoverflow.com/a/55468544/6622587:
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) h, w, ch = frame.shape bytesPerLine = ch * w disp_frame = QtGui.QImage(frame.data, w, h, bytesPerLine, QtGui.QImage.Format_RGB888)