当前位置:网站首页>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
边栏推荐
- CPU register
- PointNet原理证明与理解
- [introduction to information retrieval] Chapter 1 Boolean retrieval
- 【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》
- MMDetection安装问题
- parser. parse_ Args boolean type resolves false to true
- 【TCDCN】《Facial landmark detection by deep multi-task learning》
- 【Ranking】Pre-trained Language Model based Ranking in Baidu Search
- Thesis writing tip2
- Execution of procedures
猜你喜欢
【TCDCN】《Facial landmark detection by deep multi-task learning》
【TCDCN】《Facial landmark detection by deep multi-task learning》
[multimodal] clip model
[introduction to information retrieval] Chapter 6 term weight and vector space model
Sorting out dialectics of nature
What if the laptop can't search the wireless network signal
Mmdetection trains its own data set -- export coco format of cvat annotation file and related operations
Faster-ILOD、maskrcnn_ Benchmark training coco data set and problem summary
Semi supervised mixpatch
【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》
随机推荐
Ppt skills
ModuleNotFoundError: No module named ‘pytest‘
Win10 solves the problem that Internet Explorer cannot be installed
What if the laptop can't search the wireless network signal
Use Baidu network disk to upload data to the server
[Bert, gpt+kg research] collection of papers on the integration of Pretrain model with knowledge
【Cascade FPD】《Deep Convolutional Network Cascade for Facial Point Detection》
Use matlab to realize: chord cut method, dichotomy, CG method, find zero point and solve equation
TimeCLR: A self-supervised contrastive learning framework for univariate time series representation
【DIoU】《Distance-IoU Loss:Faster and Better Learning for Bounding Box Regression》
Generate random 6-bit invitation code in PHP
Win10+vs2017+denseflow compilation
【Mixed Pooling】《Mixed Pooling for Convolutional Neural Networks》
Using compose to realize visible scrollbar
[tricks] whiteningbert: an easy unsupervised sentence embedding approach
【MnasNet】《MnasNet:Platform-Aware Neural Architecture Search for Mobile》
[in depth learning series (8)]: principles of transform and actual combat
Drawing mechanism of view (I)
图片数据爬取工具Image-Downloader的安装和使用
【AutoAugment】《AutoAugment:Learning Augmentation Policies from Data》