import sys
import numpy as np
from PyQt5.QtWidgets import QApplication, QLabel
from PyQt5.QtGui import QImage, QPixmap
if __name__ == '__main__':
h, w = 300, 600
np_img = np.random.randint(0, 255, [h, w, 3], np.uint8)
app = QApplication(sys.argv)
q_label = QLabel()
q_label.resize(w, h)
q_img = QImage(np_img.data, np_img.shape[1], np_img.shape[0], np_img.shape[1]*3, QImage.Format_RGB888)
pix = QPixmap(q_img).scaled(q_label.width(), q_label.height())
q_label.setPixmap(pix)
q_label.show()
exit(app.exec_())
|