Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Numpy array (gray scale) to QPixmap
robopassio last edited by
My input image is at grayscale, i.e., cv_image_array, which is a numpy array.
I can successfully save it at as
or display it as
cv2.imshow("Image", cv_image_array) cv2.waitKey(1)
However, I want to display it directly on the UI
h, w = 320, 240 q_img = QImage(cv_image_array, w, h, w, QImage.Format_Grayscale8) q_pixmap = QPixmap.fromImage(gray_img).scaled(h,w) _widget.image1.setPixmap(q_pixmap)
However, the displayed image is broken and different from the one using cv2 commands
I tried a lot of time but I cannot find a solution.
Could someone please suggest some ideas to solve this?
Hi and welcome to devnet,
Are you sure the image is stored as a single channel and not RGB with only gray colors ?