当前位置:网站首页>Open3D学习笔记一【初窥门径,文件读取】
Open3D学习笔记一【初窥门径,文件读取】
2022-07-02 06:26:00 【寂云萧】
第三方库下载
pip install open3d
注意,windows在cmd安装时可能会报错,如果是安装了anaconda的话在Prompt下用pip安装。
一个简单的例子
import numpy as np
import open3d as o3d
#随机创造一些空间点
points = (np.random.rand(1000, 3) - 0.5) / 4
colors = np.random.rand(1000, 3)
#声明,再转化为点云
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points)
pcd.colors = o3d.utility.Vector3dVector(colors)
#显示
o3d.visualization.draw_geometries([pcd], window_name="3D", width=1280, height=720)
文件读取方式
1.点云读取
import open3d as o3d
print("Load a ply point cloud, print it, and render it")
pcd = o3d.io.read_point_cloud("mode/wurenji.PLY")
o3d.visualization.draw_geometries([pcd], window_name="3D", width=1280, height=720)
特点:仅支持部分文件的打开,如ply和pcd,如要打开stl,则用下面的方法
官方文档说明函数支持的格式
格式 | 描述 |
---|---|
xyz | 每行包括[x, y, z],其中x,y,z是3D坐标 |
xyzn | 每行包括[x, y, z, nx, ny, nz],其中nx、ny、nz是法线 |
xyzrgb | 每行包括[x, y, z, r, g, b],其中rgb再[0, 1]浮点数范围内 |
pts | 请查阅官方文档 |
ply | – |
pcd | – |
可以明确指定文件类型。在这种情况下,文件扩展名将被忽略。
pcd = o3d.io.read_point_cloud("../../test_data/my_points.txt", format='xyz')
2.Mesh
import open3d as o3d
print("Load a ply point cloud, print it, and render it")
#---------#
pcd = o3d.io.read_triangle_mesh("mode/mogu3.STL")
pcd.compute_vertex_normals()
#--------#
o3d.visualization.draw_geometries([pcd], window_name="3D", width=1280, height=720)
官方文档说明函数支持的格式
ply | stl | obj | off | gltf/glb |
---|
3D显示
o3d.visualization.draw_geometries()
参数:
draw_geometries(geometry_list,window_name='Open3D',width=1920,height=1080,left=50,top=50,point_show_normal=False,mesh_show_wireframe=False,mesh_show_back_face=False,lookat,up,front,zoom)
- geometry_list ( List [ open3d.geometry.Geometry ] ) – 要可视化的几何列表。
- window_name ( str , optional , default=‘Open3D’ ) – 可视化窗口的显示标题。
- width ( int , optional , default=1920 ) – 可视化窗口的宽度。
- height ( int , optional , default=1080 ) – 可视化窗口的高度。
- left ( int , optional , default=50 ) – 可视化窗口的左边距。
- top ( int , optional , default=50 ) – 可视化窗口的上边距。
- point_show_normal ( bool , optional , default=False ) – 如果设置为 true,则可视化点法线。
- mesh_show_wireframe ( bool , optional , default=False ) – 如果设置为 true,则可视化网格线框。
- mesh_show_back_face ( bool , optional , default=False ) – 也可视化网格三角形的背面。
- lookat ( numpy.ndarray [ numpy.float64 [ 3 , 1 ] ] ) – 相机的观察向量。
- up ( numpy.ndarray [ numpy.float64 [ 3 , 1 ] ] ) – 相机的向上向量。
- front ( numpy.ndarray [ numpy.float64 [ 3 , 1 ] ] ) – 相机的前向量。
- zoom ( float ) – 相机的缩放。
参考文章
https://blog.csdn.net/weixin_40511249/article/details/113557181?spm=1001.2014.3001.5502
https://blog.csdn.net/weixin_40511249/article/details/113557296?spm=1001.2014.3001.5502
https://zpcblue.blog.csdn.net/article/details/106272710?spm=1001.2014.3001.5502
边栏推荐
- [mixup] mixup: Beyond Imperial Risk Minimization
- What if the laptop task manager is gray and unavailable
- Huawei machine test questions-20190417
- Implementation of yolov5 single image detection based on pytorch
- Determine whether the version number is continuous in PHP
- 论文tips
- TimeCLR: A self-supervised contrastive learning framework for univariate time series representation
- ABM论文翻译
- Faster-ILOD、maskrcnn_ Benchmark installation process and problems encountered
- [torch] some ideas to solve the problem that the tensor parameters have gradients and the weight is not updated
猜你喜欢
【Mixup】《Mixup:Beyond Empirical Risk Minimization》
MoCO ——Momentum Contrast for Unsupervised Visual Representation Learning
传统目标检测笔记1__ Viola Jones
[introduction to information retrieval] Chapter II vocabulary dictionary and inverted record table
How do vision transformer work? [interpretation of the paper]
TimeCLR: A self-supervised contrastive learning framework for univariate time series representation
Win10+vs2017+denseflow compilation
Mmdetection installation problem
【Batch】learning notes
Alpha Beta Pruning in Adversarial Search
随机推荐
Win10 solves the problem that Internet Explorer cannot be installed
win10解决IE浏览器安装不上的问题
Apple added the first iPad with lightning interface to the list of retro products
[introduction to information retrieval] Chapter 7 scoring calculation in search system
Jordan decomposition example of matrix
[torch] some ideas to solve the problem that the tensor parameters have gradients and the weight is not updated
[CVPR‘22 Oral2] TAN: Temporal Alignment Networks for Long-term Video
Huawei machine test questions-20190417
Play online games with mame32k
【Mixed Pooling】《Mixed Pooling for Convolutional Neural Networks》
【多模态】CLIP模型
How to turn on night mode on laptop
A slide with two tables will help you quickly understand the target detection
Proof and understanding of pointnet principle
图片数据爬取工具Image-Downloader的安装和使用
【Wing Loss】《Wing Loss for Robust Facial Landmark Localisation with Convolutional Neural Networks》
【Random Erasing】《Random Erasing Data Augmentation》
What if the laptop can't search the wireless network signal
label propagation 标签传播
【Cascade FPD】《Deep Convolutional Network Cascade for Facial Point Detection》