《open3D+pyqt》第一章:点云读取、显示与保存—2

《open3D+pyqt》第一章:点云读取、显示与保存—2

新增内容

上一章节读取时,未显示点云数量,增加点云数量显示,将def read_pointcloud中更改如下即可

  def read_pointcloud(self):
        # print("test well")
        fileName, filetype = QFileDialog.getOpenFileName(self, 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
Open3D是一个独立的、开源的现代库,可用于3D数据处理和可视化。PyQt则是一个Python开发的GUI框架,可以方便地创建各种Windows、Dialog以及自定义界面。将Open3DPyQt集成后,就可以实现3D点云可视化的交互式界面。 首先,需要安装好Open3DPyQtPython模块。然后,在PyQt程序中引入Open3D模块,创建可视化窗口并定义点云对象,最后交由Open3D渲染和显示。 以下是一个简单的代码示例,以展示一个由随机3D点云组成的场景。 ```python import open3d as o3d from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout from pyqtgraph import Qt3DCore, Qt3DExtras, Qt3DRender import sys class CloudView(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): layout = QVBoxLayout(self) app = QApplication(sys.argv) container = Qt3DExtras.Qt3DWindow() container.defaultFrameGraph().setClearColor(QtGui.QColor(0, 0, 0)) root_entity = Qt3DCore.QEntity() cloud_entity = self.createPointCloud(randomPointCloud()) root_entity.addComponent(cloud_entity) container.setRootEntity(root_entity) container.show() sys.exit(app.exec_()) def createPointCloud(self, cloud): point_cloud = o3d.geometry.PointCloud() point_cloud.points = o3d.utility.Vector3dVector(cloud[:,:3]) point_cloud.colors = o3d.utility.Vector3dVector(cloud[:,3:]) entity = Qt3DCore.QEntity() mesh = Qt3DRender.QGeometryRenderer(entity) mesh.setVertexData(point_cloud.points) mesh.setColorData(point_cloud.colors) mesh.setPrimitiveType(Qt3DRender.QGeometryRenderer.Points) material = Qt3DExtras.QMetallicRoughnessMaterial(entity) material.setRoughness(0.0) material.setMetalness(0.5) entity.addComponent(mesh) entity.addComponent(material) return entity ``` 其中,createPointCloud函数接受一个numpy数组作为参数,将其转化为Open3D点云,并创建QT3DPointEntity实体、网格渲染器和材质绑定,最终返回该实体。 在initUI函数中,首先设置PyQt窗口布局和Open3D渲染窗口;接着,创建Qt3DCore.QEntity作为场景的根节点,并调用createPointCloud函数创建点云实体添加至场景中;最后,将根节点绑定至Qt3D窗口的根节点上,并启动PyQt应用程序。 运行程序后,即可在GUI中看到随机生成的3D点云场景,可支持缩放、旋转、平移等操作,实现了交互式的3D点云可视化功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小修勾

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值