PyQt加载 显示点云,已经有三种方式,使用 open3d; 使用 vtk; 使用 pcl;
下面是使用 open3d:
文章来源:https://www.toymoban.com/news/detail-672136.html
文章来源地址https://www.toymoban.com/news/detail-672136.html
import sys
import open3d as o3d
import numpy as np
import pyqtgraph.opengl as gl
from PyQt5.QtWidgets import QApplication, QVBoxLayout, QWidget, QFileDialog
from pyqtgraph.opengl import GLViewWidget
from Ui_widget import Ui_Form
class PyQtGraphicDemo(QWidget, Ui_Form):
def __init__(self, parent=None):
super(PyQtGraphicDemo, self).__init__(parent)
self.setupUi(self)
self.graphicsView = GLViewWidget(self)
self.pushButton.clicked.connect(self.showCloud)
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.addWidget(self.graphicsView)
self.verticalLayout.addWidget(self.pushButton)
self.setLayout(self.verticalLayout)
def showCloud(self):
fileName, filetype = QFileDialog.getOpenFileName(self, "请选择点云:", '.', "cloud Files(*pcd *ply)")
if fileName != '':
pcd = o3d.io.read_point_cloud(fileName) #读取点云
np_points = np.asarray(pcd.points) #获取Numpy数组
plot = gl.GLScatterPlotItem() #创建显示对象
plot.setData(pos=np_points, color=(1, 1, 1, 1), size=0.001, pxMode=False) #设置显示数据
self.graphicsView.addItem(plot) #显示点云
if __name__ == '__main__':
app = QApplication(sys.argv)
window = PyQtGraphicDemo()
window.show()
sys.exit(app.exec_())
到了这里,关于PyQt open3d 加载 显示点云的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!