I'm reading an image from my camera as a numpy array. My aim is to put it inside a Qwidget from pyqt5 and print on my mainwindow gui program, but i'm getting the following error:
TypeError: QPixmap(): argument 1 has unexpected type 'numpy.ndarray'
Here is the code:
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from epics import PV
import numpy as np
class PanoramicGUI:
def __init__(self):
self.MainWindow = uic.loadUi('panoramicGUI.ui')
self.MainWindow.SavePositionButton. clicked.connect(self.save_image)
def save_image(self):
detectorData = PV("CAMERA:DATA")
self.data = detectorData.get()
self.data = np.array(self.data).reshape(2048,2048).astype(np.int32)
print(self.data)
img = PrintImage(QPixmap(self.data))
self.MainWindow.WidgetHV1X1.setLayout(QtWidgets.QVBoxLayout())
self.MainWindow.WidgetHV1X1.layout().addWidget(img)
class PrintImage(QWidget):
def __init__(self, pixmap, parent=None):
QWidget.__init__(self, parent=parent)
self.pixmap = pixmap
def paintEvent(self, event):
painter = QPainter(self)
painter.drawPixmap(self.rect(), self.pixmap)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
panoramic = PanoramicGUI()
panoramic.MainWindow.show()
app.exec_()
Can someone help me?
Regards,
Gabriel.