记录一下:
def show_img(self, mat):
# cv2.imwrite("5.jpg", data) # ok
self.label.clear()
if mat is not None:
# image_height, image_width = mat.shape # 读取图像高宽深度
# print("he", image_height)
# print("wi", image_width)
# qim = QImage(mat.data, image_width, image_height, image_width * 3, QImage.Format_RGB888) # 彩色图像
qim = QImage(mat[:], mat.shape[1], mat.shape[0], QImage.Format_Indexed8) # 灰度图像
pix = QPixmap(qim).scaled(self.label.width(), self.label.height())
self.label.setPixmap(pix)
self.label.setScaledContents(True)