I touched on Open3D in my graduation research, but when I first started touching Open3D, I was in trouble because there was too little Japanese information, so I will summarize it a little.
A site that most people who have started to touch Open3D will probably reach → Open3D: http://lang.sist.chukyo-u.ac.jp/classes/Open3D/ This is a Japanese translation of the official tutorial, but there are many things you can do besides the tutorial. If you have something you want to do, you can usually find it in the Official Documentation (http://www.open3d.org/docs/release/index.html).
In my research, I did "point cloud generation from RGB-D camera images", "removal of outliers", "point cloud alignment", etc. Other things I did were "voxelization of point clouds" and "plane estimation using RANSAC".
This time, I will write about the basics of Open3D and "voxelization of point clouds" (although it is just an introduction to functions).
Please note that the specifications of Open3D differ greatly depending on the version. In this article, it is described for v0.9.0, but since I also used v0.7.0 for my research, I have only checked the minimum operation with v0.9.0.
Point cloud generation and visualization from RGB-D images, reading and writing to pcd files
The upper right is the image acquired from RealSense, and the left is the point cloud generated (in the research, the point cloud was generated after cutting the image).
import open3d as o3d
"""
RGB to Open3D-D image input
"""
color = o3d.Image(color_numpy) #Convert from numpy array
depth = o3d.Image(depth_numpy)
rgbd = o3d.geometry.RGBDImage.create_rgbd_image_from_color_and_depth(color, depth, convert_rgb_to_intensity=False)
pcd = o3d.geometry.PointCloud.create_point_cloud_from_rgbd_image(rgbd, pinhole_camera_intrinsic)
pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]]) #Rotation for easy viewing
You can get pinhole_camera_intrinsic by the following method if you use RealSense. Processing such as RealSense settings is omitted.
import pyrealsense2 as rs
#Get camera intrinsics
intr = profile.get_stream(rs.stream.color).as_video_stream_profile().get_intrinsics()
pinhole_camera_intrinsic = o3d.camera.PinholeCameraIntrinsic(intr.width, intr.height, intr.fx, intr.fy, intr.ppx, intr.ppy)
o3d.visualization.draw_geometries([pcd])
It is also used for visualization of voxels and meshes as well as point clouds.
#Writing in binary
o3d.io.write_point_cloud("hoge.pcd", pcd)
#Writing in ascii
o3d.io.write_point_cloud("hoge.pcd", pcd, True)
You can output other than pcd files. It is convenient to output ascii because it is easy to see.
pcd = o3d.io.read_point_cloud("./hoge.pcd")
voxel = o3d.geometry.VoxelGrid.create_from_point_cloud(pcd, 0.03) #Voxel size specification
o3d.visualization.draw_geometries([voxel])
When I touched Open3D, I created a voxelization function for the point cloud by myself, but it seems that it was originally prepared. .. ..
This time I summarized the basics of Open3D. If I have time, I would like to summarize my research and plane estimation with RANSAC, but I probably won't.