我试图建立一个使用vtk和pyqt5显示Dicom图像的GUI,我成功运行了代码并显示了图像,右键单击是正常的,可以放大和缩小,但是当我单击向左按钮,它停住了并显示“进程已完成,退出代码为-1073740940(0xC0000374)”。
我的python版本是3.7,我认为原因是qvtk和vtkimageshow之间的热键冲突,但是我不知道如何解决它。
ReadDicom(QtWidgets.QMainWindow)类:
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)
self.frame = QtWidgets.QFrame()
self.vl = QtWidgets.QVBoxLayout()
self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
self.vl.addWidget(self.vtkWidget)
reader = vtk.vtkDICOMImageReader()
#reader.SetDataByteOrderToLittleEndian()
reader.SetFileName(
"E:\Projects\IMG-0002-00085.dcm")
reader.Update()
# viewer actor->render->renderwindow
viewer = vtk.vtkImageViewer2()
viewer.SetInputConnection(reader.GetOutputPort())
# mapper
#self.vtkWidget.SetRenderWindow(viewer.GetRenderWindow())
viewer.SetupInteractor(self.vtkWidget.GetRenderWindow().GetInteractor())
viewer.SetRenderWindow(self.vtkWidget.GetRenderWindow())
viewer.Render()
viewer.GetRenderer().ResetCamera()
self.frame.setLayout(self.vl)
self.setCentralWidget(self.frame)
self.show()#qt
self.vtkWidget.Initialize()