Pyqt4 + opencv display pictures in Qlabel

self.imgName = QFileDialog.getOpenFileName (None, “open image”, “/ home / lvnianzu / picture”, “All Files ( ) ;; .tif ;; *. gif”) ## Open the folder dialog and select the file And get the file path
self.imgName = unicode (self.imgName)
self.patient_img = np.asarray (Image.open (self.imgName)) ## Do not open a new section of memory to save data, the array will open a new section New memory
self.patient_img = cv.resize (self.patient_img, (560, 560))
showImage = QtGui.QImage (self.patient_img.data, self.patient_img.shape [1], self.patient_img.shape [0] , QtGui.QImage.Format_RGB888)
self.label.height (), QtGui.QImage.Format_RGB888)
self.label.setPixmap (QtGui.QPixmap.fromImage (showImage))
self.label.setScaledContents (True) #Set the picture to fill the whole label

Published 36 original articles · won praise 1 · views 6384

Guess you like

Origin blog.csdn.net/qq_34291583/article/details/90646756