如何使用 vtk 在 python 中绘制可鼠标旋转的点云

How to draw mouse-rotatable point cloud in python with vtk

我需要在python中绘制可旋转的点云,这是我在网上找到的:

import vtk_visualizer as vv
import numpy as np
xyz = np.random.rand(1000, 3)
vtkControl = vv.VTKVisualizerControl()
vtkControl.AddPointCloudActor(xyz)
vtkControl.Render()
vtkControl.ResetCamera()

显示 window 片刻,然后 window 隐藏,所以我无法用鼠标旋转它。我该如何解决?

这是我找到的解决方案:

import vtk_visualizer as vv
import numpy as np
import sys
from PyQt5.QtWidgets import *
xyz = np.random.rand(1000, 3)
vtkControl = vv.VTKVisualizerControl()
vtkControl.AddPointCloudActor(xyz)
app = QApplication.instance()
if app is None:
    app = QApplication(sys.argv)
app.exec_()