当将vtkImageViewer2与PyQt5一起使用以显示dicom图像时,单击鼠标左键将导致退出代码-1073740940(0xC0000374)

时间:2019-07-17 18:56:40

标签: pyqt5 vtk dicom qvtkwidget

我试图建立一个使用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()

0 个答案:

没有答案