- Introduction
Open3D是什么?
Open3D是支持快速处理3D对象的开源库(对比OpenCV对图像的支持)
感谢作者:Qianyi Zhou http://qianyi.info/
支持语言:Python, C++
依赖:Numpy
官方网站:http://www.open3d.org/
文档与教程:http://www.open3d.org/docs/
Installation
- 从Pypi安装
pip install –user open3d-python
或python3 -m pip install –user open3d-python
- 从source安装
$ git clone https://github.com/IntelVCL/Open3D
Windows:
Cmake GUI + VS2015(2017)
对ALL和INSTALL项目分别生成解决方案
Ubuntu:$ util/scripts/install-deps-ubuntu.sh
$ mkdir build
$ cd build
$ cmake ../src -DCMAKE_INSTALL_PREFIX=open3d_install_directory
$ make –j
检验安装成功,Python中输入:import open3d
help(open3d)
For more information: http://www.open3d.org/docs/tutorial/Basic/python_interface.html
- 从Pypi安装
Module Overview
其中Geometry包含以下三种表现形式的数据结构RGB-D Image Pointcloud Mesh
Geometry Detail
Image
color_raw = read_image(“../../TestData/RGBD/color/00000.jpg”)
depth_raw = read_image(“../../TestData/RGBD/depth/00000.png”)
rgbd_image = create_rgbd_image_from_color_and_depth(color_raw, depth_raw)
plt.subplot(1, 2, 1)
plt.imshow(rgbd_image.color)
plt.subplot(1, 2, 2)
plt.imshow(rgbd_image.depth)
plt.show()
Pointcloud
pcd = read_point_cloud(“../../TestData/fragment.ply“)
# 支持:pcd ply xyz xyzrgb xyzn ptsdownpcd = voxel_down_sample(pcd, voxel_size = 0.05)
estimate_normals(downpcd, search_param = KDTreeSearchParamHybrid(radius = 0.1, max_nn = 30))
chair = vol.crop_point_cloud(pcd)
vol = read_selection_polygon_volume(“../../TestData/Crop/cropped.json”)
chair.paint_uniform_color([1, 0.706, 0])
draw_geometries([chair])
属性:
np.asarray(pcd.points)
pcd.normal
pcd.colors
其他方法:
pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])Mesh
mesh = read_triangle_mesh(“../../TestData/knot.ply”)
if (not mesh.has_vertex_normal): mesh.compute_vertex_normals()
mesh.paint_uniform_color([r, g, b])
draw_geometris([mesh])
属性:
mesh.triangles
mesh.triangle_normal
mesh1.triangles = Vector3iVector(np.asarray(mesh1.triangles)[:len(mesh1.triangles)//2, :])
mesh.vertices
mesh.vertice_colors
mesh.vertice_normalsMesh - 自造元素
mesh_sphere = create_mesh_sphere(radius = 1.0)
mesh_sphere.compute_vertex_normals()
mesh_sphere.paint_uniform_color([0.1, 0.1, 0.7])
mesh_cylinder = create_mesh_cylinder(radius = 0.3, height = 4.0)
mesh_cylinder.compute_vertex_normals()
mesh_cylinder.paint_uniform_color([0.1, 0.9, 0.1])
mesh_frame = create_mesh_coordinate_frame(size = 0.6, origin = [-2, -2, -2])
Reconstruction Workflow
Input: RGB-D Image- 特征提取和图像匹配
- Matching pairs
- Robust Pose Graph Optimization
- Volumetric integration
- 估算相机参数
- Global Registration
- Robust pose optimization
- ICP Registration
- Global non-rigid alignment
- 重建点云 ply
网格化 mesh
可以由image直接生成点云
pcd = create_point_cloud_from_rgbd_image(rgbd_image, PinholeCameraIntrinsic(PinholeCameraIntrinsicParameters.PrimeSenseDefault))
也可由Odometry:读两幅RGBD图,计算刚体变换
source_rgbd_image, target_rgbd_image
option = OdometryOption()
odo_init = np.identity(4)
[success_hybrid_term, trans_hybrid_term, info] = compute_rgbd_odometry( source_rgbd_image, target_rgbd_image, pinhole_camera_intrinsic, odo_init, RGBDOdometryJacobianFromHybridTerm(), option)
source_pcd_hybrid_term = create_point_cloud_from_rgbd_image(source_rgbd_image, pinhole_camera_intrinsic)
source_pcd_hybrid_term.transform(trans_hybrid_term)
draw_geometries([target_pcd, source_pcd_hybrid_term])ICP registration
threshold = 0.02
trans_init = np.asarray(4*4 matrix) # acquire from global registration
reg_p2l = registration_icp(source, target, threshold, trans_init, transformationEstimationPointToPlane()) # TransformationEstimationPointToPoint
draw_registration_result(source, target, reg_p2l.transformation)
- 特征提取和图像匹配
Advanced Part
KDTree找邻近点:
pcd_tree = KDTreeFlann(pcd)
[k, idx, variant] = pcd_tree.search_knn_vector_3d(pcd.points[1500], 200)
[k, idx, variant] = pcd_tree.search_radius_vector_3d(pcd.points[1500], 0.2)
np.asarray(pcd.colors)[idx[1:], :] = [0, 0, 1]
RANSAC Global Registration
http://www.open3d.org/docs/tutorial/Advanced/global_registration.html- Multiway registration
http://www.open3d.org/docs/tutorial/Advanced/multiway_registration.html - Advanced Visualization:
Callback, non-blocking, customized (FoV, animation, …) - RGBD integration