Open3d API

Open3D API

[TOC]

Open3D demo

文件读取

PointCloud:

  • 1 文件读取
  • 2 数组数据读取
1
2
3
4
print("Testing IO for point cloud ...")
pcd = o3d.io.read_point_cloud("../../TestData/fragment.pcd")
print(pcd)
o3d.io.write_point_cloud("copy_of_fragment.pcd", pcd)
1
2
source = o3d.io.read_point_cloud("../TestData/ICP/cloud_bin_0.pcd")
target = o3d.io.read_point_cloud("../TestData/ICP/cloud_bin_1.pcd")

TriMesh:

1
2
3
4
print("Testing IO for meshes ...")
mesh = o3d.io.read_triangle_mesh("../../TestData/knot.ply")
print(mesh)
o3d.io.write_triangle_mesh("copy_of_knot.ply", mesh)

Image:

1
2
3
4
print("Testing IO for textured meshes ...")
textured_mesh = o3d.io.read_triangle_mesh("../../TestData/crate/crate.obj")
print(textured_mesh)
o3d.io.write_triangle_mesh("copy_of_crate.obj",

TriMesh to PointCloud v1

​ triMesh完全PointCloud读取

1
2
3
4
5
6
7
8
9
10
11
12
def load_ply_point_cloud(filename,voxel_size=0.5):
print("Load a ply point cloud, print it, and render it")
mesh= open3d.io.read_triangle_mesh(filename)
voxel_mesh = open3d.geometry.VoxelGrid.create_from_triangle_mesh(mesh)
return mesh,voxel_mesh

points_ar = []
for x in voxel_mesh.voxels:
points_ar.append(x.grid_index)
points = np.array(points_ar)
pcd = open3d.geometry.PointCloud()
pcd.points = open3d.utility.Vector3dVector(points)

TriMesh to PointCloud v2

​ 采样的方式,进行采用PointCloud

sample_points_poisson_disk(*self*, number_of_points**,** init_factor=5**,** pcl=None**)**

​ 函数从网格中取样点,其中每个点到邻近点的距离大致相同(蓝色噪声)。 方法是基于 Yuksel

sample_points_uniformly(*self 自我*, number_of_points=100 点数100**)**

​ 函数来均匀地从网格中取样点。

1
2
3
print("Load a ply point could, print, render it")
mesh= open3d.io.read_triangle_mesh(filename)
o3d.geometry.TriangleMesh.sample_points_uniformly(mesh, voxel_size)

Voxel

Base Voxel class, containing grid id and color

基本体素类,包含网格 id 和颜色

VoxelGrid

open3d.geometry.VoxelGrid

可视化

1
2
source = o3.io.read_point_cloud(mscan)
o3.visualization.draw_geometries([source])

API detail

open3d.gemotry.TriangleMesh

staticcreate_from_point_cloud_alpha_shape(*pcd*, alpha**,** tetra_mesh**,** pt_map**)**

staticcreate_from_point_cloud_ball_pivoting(*pcd*, radii**)**

staticcreate_from_point_cloud_poisson(*pcd*, depth=8**,** width=0**,** scale=1.1**,** linear_fit=False**)**

open3d.registration.registration_ransac_based_on_feature_matching

Parameters

Returns

​ open3d.registration.RegistrationResult

open3d.registration.RegistrationResult

  • propertycorrespondence_set

    Correspondence set between source and target point cloud.Typen x 2 int numpy array

    源点云与目标点云之间的对应集[source, target]。(此处的源点云与目标点云,均是采样过后的对应关系之间)

  • propertyfitness

    The overlapping area (# of inlier correspondences / # of points in target). Higher is better.Typefloat

    重叠区域(向内对应的 # / 目标点的 #)。越高越好。

  • propertyinlier_rmse

    RMSE of all inlier correspondences. Lower is better.Typefloat

    所有相关函数的 RMSE。越低越好。

  • propertytransformation

    The estimated transformation matrix.Type4 x 4 float64 numpy array

    估计的变换矩阵。

open3d.registration.CorrespondenceCheckerBasedOnDistance

​ Class to check if aligned point clouds are close (less than specified threshold).

​ 检查对齐的点云是否关闭(小于指定的阈值)。

open3d.registration.CorrespondenceCheckerBasedOnEdgeLength

​ Check if two point clouds build the polygons with similar edge lengths. That is, checks if the lengths of any two arbitrary edges (line formed by two vertices) individually drawn withinin source point cloud and within the target point cloud with correspondences are similar. The only parameter similarity_threshold is a number between 0 (loose) and 1 (strict)

​ 检查两个点云是否构建边长相似的多边形。 也就是说,检查在源点云和目标点云中单独绘制的任意两条边(由两个顶点组成的直线)的长度是否相似。 唯一的参数相似性阈值是介于0(宽松)和1(严格)之间的数字

open3d.registration.RANSACConvergenceCriteria

​ 定义 RANSAC 的收敛准则。 如果迭代次数达到最大迭代次数,或者验证已经运行了最大验证次数,则 RANSAC 算法停止。 注意,验证是迭代中最昂贵的计算运算符。 大多数迭代并不完全进行验证。 这是至关重要的,以控制最大验证,使计算时间是可接受的。

open3d.geometry.PointCloud

​ crop(bounding_box, bounding_box**)**

open3d.geometry.OrientedBoundingBox

​ static create_from_points

​ get_max_bound(self)

get_min_bound(self)

get_oriented_bounding_box