{"id":2055,"date":"2021-08-11T09:26:41","date_gmt":"2021-08-11T01:26:41","guid":{"rendered":"http:\/\/www.yatenglg.cn\/?p=2055"},"modified":"2022-10-18T16:34:39","modified_gmt":"2022-10-18T08:34:39","slug":"open3d-%e7%82%b9%e4%ba%91%e5%8f%8a%e5%85%b6%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"http:\/\/www.yatenglg.cn\/blog\/?p=2055","title":{"rendered":"open3d-\u70b9\u4e91\u53ca\u5176\u64cd\u4f5c"},"content":{"rendered":"\n<p>open3d\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e13\u95e8\u7528\u4e8e\u70b9\u4e91\u7684\u6570\u636e\u7ed3\u6784 <strong>PointCloud<\/strong>\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>class PointCloud(Geometry3D):\n    color   # \u989c\u8272\n    normals # \u6cd5\u5411\u91cf\n    points  # \u70b9\u4e91\n    def __init__(self, *args, **kwargs):\n        &quot;&quot;&quot;\n        __init__(*args, **kwargs)\n        Overloaded function.\n        1. __init__(self: open3d.cpu.pybind.geometry.PointCloud) -&gt; None\n        Default constructor\n        2. __init__(self: open3d.cpu.pybind.geometry.PointCloud, arg0: open3d.cpu.pybind.geometry.PointCloud) -&gt; None\n        Copy constructor\n        3. __init__(self: open3d.cpu.pybind.geometry.PointCloud, points: open3d.cpu.pybind.utility.Vector3dVector) -&gt; None\n        Create a PointCloud from points\n        &quot;&quot;&quot;\n    # dbscan\u805a\u7c7b\n    def cluster_dbscan(self, eps, min_points, print_progress=False):\n    # \u8ba1\u7b97\u51f8\u5305\n    def compute_convex_hull(self):\n    # \u8ba1\u7b97\u9a6c\u6c0f\u8ddd\u79bb\u3002 \u8fd4\u56de\u6bcf\u4e2a\u70b9\u7684\u9a6c\u6c0f\u8ddd\u79bb\n    def compute_mahalanobis_distance(self):\n    # \u8ba1\u7b97\u5747\u503c\u4e0e\u534f\u65b9\u5dee\u77e9\u9635\n    def compute_mean_and_covariance(self): \n    # \u8ba1\u7b97\u70b9\u4e91\u6bcf\u4e2a\u70b9\u5230\u5176\u6700\u8fd1\u70b9\u7684\u8ddd\u79bb\n    def compute_nearest_neighbor_distance(self):\n    # \u8ba1\u7b97\u5f53\u524d\u70b9\u4e91\u6bcf\u4e2a\u70b9\u5230\u76ee\u6807\u70b9\u4e91\u7684\u6700\u8fd1\u8ddd\u79bb\n    def compute_point_cloud_distance(self, target):\n    def create_from_depth_image(self, depth, intrinsic, extrinsic, *args, **kwargs):\n    def create_from_rgbd_image(self, image, intrinsic, extrinsic, *args, **kwargs):\n    # \u88c1\u526a\u3002 \u8f93\u5165\u4e00\u4e2aaabb\u6846\u6216obb\u6846\n    def crop(self, *args, **kwargs):\n    # \u8ba1\u7b97\u9876\u70b9\u6cd5\u5411\u91cf\n    def estimate_normals(self, search_param=None, *args, **kwargs):\n    # \u662f\u5426\u6709color\n    def has_colors(self):\n    # \u662f\u5426\u6709\u6cd5\u5411\u91cf\n    def has_normals(self):\n    # \u662f\u5426\u6709\u70b9\u4e91\u70b9\n    def has_points(self):    \n    # \u9690\u85cf\u70b9\u53bb\u9664\u3002 \n    def hidden_point_removal(self, camera_location, radius):\n    # \u5f52\u4e00\u5316\u6cd5\u5411\u91cf\u3002 \u6cd5\u5411\u91cf\u957f\u5ea6\u4e3a1\n    def normalize_normals(self):\n    # \u6cd5\u5411\u91cf\u65b9\u5411\u4e00\u81f4\n    def orient_normals_consistent_tangent_plane(self, k):\n    # \u6cd5\u5411\u91cf\u65b9\u5411\u4e00\u81f4\u3002 \u6307\u5b9a\u76f8\u673a\u4f4d\u7f6e\n    def orient_normals_towards_camera_location(self, camera_location=None, *args, **kwargs):\n    # \u6cd5\u5411\u91cf\u65b9\u5411\u4e00\u81f4\u3002 \u6307\u5b9a\u53c2\u8003\u65b9\u5411\n    def orient_normals_to_align_with_direction(self, orientation_reference=None, *args, **kwargs):\n    # \u4e0a\u8272\u3002 \u989c\u8272rgb\uff0c\u8303\u56f40~1\n    def paint_uniform_color(self, color):\n    # \u968f\u673a\u4e0b\u91c7\u6837\u3002 \u6307\u5b9a\u4e0b\u91c7\u6837\u7387\n    def random_down_sample(self, sampling_ratio):\n    # \u5220\u9664non \u548c inf \u503c\u7684\u70b9\n    def remove_non_finite_points(self, remove_nan=True, remove_infinite=True):   \n    # \u5220\u9664\u6307\u5b9a\u534a\u5f84\u5185\u5c11\u4e8e\u6307\u5b9a\u70b9\u6570\u7684\u70b9\n    def remove_radius_outlier(self, nb_points, radius):\n    # \u5220\u9664\u76f8\u90bb\u70b9\u4e2d\u8ddd\u79bb\u5927\u4e8e\u5e73\u5747\u8ddd\u79bb\u7684\u70b9\n    def remove_statistical_outlier(self, nb_neighbors, std_ratio):\n    # \u5e73\u9762\u5206\u5272\n    def segment_plane(self, distance_threshold, ransac_n, num_iterations):\n    # \u6309\u7167\u4e0b\u6807\u7b5b\u9009\u70b9\u4e91\n    def select_by_index(self, indices, invert=False):\n    # \u4e0b\u91c7\u6837\u3002 \u6bcf\u9694\u591a\u5c11\u4e2a\u70b9\u53d6\u4e00\u4e2a\n    def uniform_down_sample(self, every_k_points):\n    # \u4f53\u7d20\u4e0b\u91c7\u6837\u3002 \u6307\u5b9a\u4f53\u7d20\u5c3a\u5bf8\n    def voxel_down_sample(self, voxel_size):\n    # \u4f53\u7d20\u4e0b\u91c7\u6837\u5e76\u8bb0\u5f55\u539f\u6570\u636e\u3002 \u6307\u5b9a\u4f53\u7d20\u5c3a\u5bf8\n    def voxel_down_sample_and_trace(self, voxel_size, min_bound, max_bound, approximate_class=False): \n    <\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>import numpy as np\nimport open3d as o3d\nfrom open3d.web_visualizer import draw\nfrom open3d.visualization import draw_geometries<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>pcd = o3d.io.read_point_cloud(&#39;datas\/fragment.ply&#39;)\ndraw(pcd)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"430\" height=\"296\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-Z0LU70.png\" alt=\"\" class=\"wp-image-2057\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-Z0LU70.png 430w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-Z0LU70-300x207.png 300w\" sizes=\"(max-width: 430px) 100vw, 430px\" \/><\/figure>\n\n\n\n<h2>1.\u4f53\u7d20\u4e0b\u91c7\u6837<\/h2>\n\n\n\n<p>open3d.geometry.PointCloud \u63d0\u4f9b\u4e86 <strong>voxel_down_sample(self, voxel_size)<\/strong> \u65b9\u6cd5\uff0c\u6765\u8fdb\u884c\u4f53\u7d20\u4e0b\u91c7\u6837\u64cd\u4f5c\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>    def voxel_down_sample(self, voxel_size):\n        &quot;&quot;&quot;\n        voxel_down_sample(self, voxel_size)\n        \u5bf9\u8f93\u5165\u70b9\u4e91\u8fdb\u884c\u4f53\u7d20\u4e0b\u91c7\u6837\uff0c\u5982\u679c\u6cd5\u7ebf\u548c\u989c\u8272\u5b58\u5728\uff0c\u5219\u6cd5\u7ebf\u548c\u989c\u8272\u53d6\u5747\u503c\u3002\n\n        Args:\n            voxel_size (float): \u4f53\u7d20\u5c3a\u5bf8\n\n        Returns:\n            open3d.geometry.PointCloud\n        &quot;&quot;&quot;<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>downsample = pcd.voxel_down_sample(voxel_size=0.05)\ndraw(downsample)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"463\" height=\"309\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-605D80.png\" alt=\"\" class=\"wp-image-2059\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-605D80.png 463w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-605D80-300x200.png 300w\" sizes=\"(max-width: 463px) 100vw, 463px\" \/><\/figure>\n\n\n\n<h2>2. \u9876\u70b9\u6cd5\u5411\u91cf\u4f30\u8ba1<\/h2>\n\n\n\n<p>open3d.geometry.PointCloud \u63d0\u4f9b\u4e86 <strong>estimate_normals(self, voxel_size)<\/strong> \u65b9\u6cd5\uff0c\u6765\u8ba1\u7b97\u9876\u70b9\u6cd5\u5411\u91cf\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>    def estimate_normals(self, search_param=None, *args, **kwargs): \n        &quot;&quot;&quot;\n        estimate_normals(self, search_param=KDTreeSearchParamKNN with knn = 30, fast_normal_computation=True)        \n        Args:\n            search_param (open3d.geometry.KDTreeSearchParam, optional): \u7528\u4e8e\u9886\u57df\u641c\u7d22\u7684KDTree\u641c\u7d22\u53c2\u6570\u3002 \u9ed8\u8ba4\u503c\u4e3a\uff1aKDTreeSearchParamKNN with knn = 30\n            fast_normal_computation (bool, optional, default=True): \u5982\u679c\u4e3atrue\uff0c\u901a\u8fc7\u534f\u65b9\u5dee\u77e9\u9635\u8ba1\u7b97\u7279\u5f81\u5411\u91cf\uff0c\u901f\u5ea6\u66f4\u5feb\uff0c\u4f46\u6570\u503c\u4e0d\u7a33\u5b9a\u3002\u5982\u679c\u4e3aFalse,\u5219\u4f7f\u7528\u8fed\u4ee3\u65b9\u5f0f\u3002\n\n        Returns:\n            None   \u65e0\u8fd4\u56de\u503c\uff0c\u6cd5\u5411\u91cf\u76f4\u63a5\u5b58\u50a8\u4e8e PointCloud.normals \n        &quot;&quot;&quot;<\/code><\/pre><\/div>\n\n\n\n<p>search_param \u53c2\u6570\u6709:<\/p>\n\n\n\n<ul><li>class KDTreeSearchParamHybrid(KDTreeSearchParam):<br>def <strong>init<\/strong>(self, radius, max_nn): # \u641c\u7d22\u534a\u5f84\u3001\u6700\u5927\u8fd1\u90bb\u70b9\u6570<\/li><li>class KDTreeSearchParamKNN(KDTreeSearchParam):<br>def <strong>init<\/strong>(self, knn=30): # \u8fd1\u90bb\u70b9\u6570<\/li><li>class KDTreeSearchParamRadius(KDTreeSearchParam):<br>def <strong>init<\/strong>(self, radius): # \u641c\u7d22\u534a\u5f84<\/li><\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>downsample.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.1, max_nn=30))\n\n# \u6b64\u5904\u4f7f\u7528 draw_geometries\u7ed8\u5236\u70b9\u4e91\u4ee5\u53ca\u6cd5\u7ebf\u3002\ndraw_geometries([downsample], point_show_normal=True)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"597\" height=\"414\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-YLTZ70.png\" alt=\"\" class=\"wp-image-2060\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-YLTZ70.png 597w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-YLTZ70-300x208.png 300w\" sizes=\"(max-width: 597px) 100vw, 597px\" \/><\/figure>\n\n\n\n<h2>3. \u88c1\u526a\u70b9\u4e91<\/h2>\n\n\n\n<p>\u88c1\u526a\u70b9\u4e91\uff0c\u9996\u5148\u9700\u8981\u786e\u5b9a\u88c1\u526a\u533a\u57df<\/p>\n\n\n\n<p>\u901a\u8fc7<strong>o3d.visualization.read_selection_polygon_volume()<\/strong>\u51fd\u6570\uff0c\u8bfb\u53d6\u4e00\u4e2a\u591a\u8fb9\u5f62\u533a\u57df\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u901a\u8fc7\u591a\u8fb9\u5f62\u88c1\u526a\u70b9\u4e91\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>def read_selection_polygon_volume(filename): \n    &quot;&quot;&quot;\n    read_selection_polygon_volume(filename)\n    Function to read SelectionPolygonVolume from file\n\n    Args:\n        filename (str): The file path.\n\n    Returns:\n        open3d.visualization.SelectionPolygonVolume\n    &quot;&quot;&quot;\n    pass<\/code><\/pre><\/div>\n\n\n\n<p>open3d.visualization.SelectionPolygonVolume \u542b\u6709\u4e24\u4e2a\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<ul><li>crop_point_cloud(input)<\/li><li>crop_triangle_mesh(input)<\/li><\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code># \u8bfb\u53d6\u591a\u8fb9\u5f62\nvol = o3d.visualization.read_selection_polygon_volume(&#39;datas\/cropped.json&#39;)\nchair = vol.crop_point_cloud(pcd)\ndraw(chair)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"402\" height=\"379\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-BPN170.png\" alt=\"\" class=\"wp-image-2061\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-BPN170.png 402w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-BPN170-300x283.png 300w\" sizes=\"(max-width: 402px) 100vw, 402px\" \/><\/figure>\n\n\n\n<h2>4. \u70b9\u4e91\u4e0a\u8272<\/h2>\n\n\n\n<p>open3d.geometry.PointCloud \u63d0\u4f9b\u4e86 <strong>paint_uniform_color(self, color)<\/strong>\u65b9\u6cd5\uff0c\u6765\u4e3a\u70b9\u4e91\u8fdb\u884c\u4e0a\u8272\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>def paint_uniform_color(self, color): \n    &quot;&quot;&quot;\n    paint_uniform_color(self, color)\n    Assigns each point in the PointCloud the same color.\n\n    Args:\n        color (numpy.ndarray[float64[3, 1]]):RGB\u989c\u8272\uff0c\u503c\u57280~1\u8303\u56f4\u5185\n\n    Returns:\n        open3d.geometry.PointCloud\n    &quot;&quot;&quot;\n    pass<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>chair.paint_uniform_color([1,0,0])  # \u7ea2\u8272\ndraw(chair)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"393\" height=\"389\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-T1UW70.png\" alt=\"\" class=\"wp-image-2062\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-T1UW70.png 393w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-T1UW70-300x297.png 300w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-T1UW70-100x100.png 100w\" sizes=\"(max-width: 393px) 100vw, 393px\" \/><\/figure>\n\n\n\n<h2>5. \u70b9\u4e91\u8ddd\u79bb\u4e0e\u7b5b\u9009<\/h2>\n\n\n\n<p>open3d.geometry.PointCloud \u63d0\u4f9b\u4e86 <strong>compute_point_cloud_distance(self, target)<\/strong>\u65b9\u6cd5\uff0c\u8ba1\u7b97\u5f53\u524d\u70b9\u4e91\u4e2d\u6bcf\u4e2a\u70b9\u5230\u76ee\u6807\u70b9\u4e91\u4e2d\u70b9\u7684\u6700\u8fd1\u8ddd\u79bb\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>def compute_point_cloud_distance(self, target):\n    &quot;&quot;&quot;        \n    Args:\n        target (open3d.geometry.PointCloud): \u76ee\u6807\u70b9\u4e91\n\n    Returns:\n        open3d.utility.DoubleVector\n    &quot;&quot;&quot;<\/code><\/pre><\/div>\n\n\n\n<p>open3d.geometry.PointCloud \u63d0\u4f9b\u4e86 <strong>select_by_index(self, indices, invert=False)<\/strong>\u65b9\u6cd5\uff0c\u901a\u8fc7\u4e0b\u6807\u6765\u7b5b\u9009\u70b9\u4e91\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>def select_by_index(self, indices, invert=False):\n    &quot;&quot;&quot;\n    select_by_index(self, indices, invert=False)        \n    Args:\n        indices (List[int]): \u4e0b\u6807\n        invert (bool, optional, default=False): \u53cd\u9009\n\n    Returns:\n        open3d.geometry.PointCloud\n    &quot;&quot;&quot;<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>dists = pcd.compute_point_cloud_distance(chair)  # \u8ba1\u7b97\u6574\u4f53\u70b9\u4e91\u4e2d\uff0c\u6bcf\u4e2a\u70b9\u5230\u6905\u5b50\u70b9\u4e91\u4e2d\u6700\u8fd1\u70b9\u7684\u8ddd\u79bb\u3002\ndists = np.array(dists)\nind = np.where(dists &gt; 0.01)[0]  # \u83b7\u53d6\u8ddd\u79bb\u5927\u4e8e0.01\u7684\u70b9\u7684\u4e0b\u6807\npcd_without_chair = pcd.select_by_index(ind)  # \u901a\u8fc7\u4e0b\u6807\u7b5b\u9009\u70b9\u4e91\u4e2d\u70b9\ndraw(pcd_without_chair)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"474\" height=\"351\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-G1X770.png\" alt=\"\" class=\"wp-image-2063\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-G1X770.png 474w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-G1X770-300x222.png 300w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/figure>\n\n\n\n<h2>6. \u8fb9\u754c\u6846<\/h2>\n\n\n\n<p>o3d.geometry.Geometry3D \u63d0\u4f9b\u4e86 <strong>get_axis_aligned_bounding_box()<\/strong> \u65b9\u6cd5\uff0c\u6765\u83b7\u53d6aabb\u5305\u56f4\u76d2\uff08\u8f74\u5bf9\u9f50\u5305\u56f4\u76d2\uff09<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>def get_axis_aligned_bounding_box(self):\n    &quot;&quot;&quot;\n    get_axis_aligned_bounding_box(self)        \n    Returns:\n        open3d.geometry.AxisAlignedBoundingBox\n    &quot;&quot;&quot;<\/code><\/pre><\/div>\n\n\n\n<p>o3d.geometry.Geometry3D \u63d0\u4f9b\u4e86 <strong>get_oriented_bounding_box()<\/strong> \u65b9\u6cd5\uff0c\u6765\u83b7\u53d6obb\u5305\u56f4\u76d2\uff08\u6709\u5411\u5305\u56f4\u76d2\uff09<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>def get_oriented_bounding_box(self):\n    &quot;&quot;&quot;\n    Returns:\n        open3d.geometry.OrientedBoundingBox\n    &quot;&quot;&quot;<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>aabb = chair.get_axis_aligned_bounding_box()\nprint(aabb)\ndraw([chair, aabb])<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"447\" height=\"377\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-5W2W70.png\" alt=\"\" class=\"wp-image-2064\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-5W2W70.png 447w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-5W2W70-300x253.png 300w\" sizes=\"(max-width: 447px) 100vw, 447px\" \/><\/figure>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>obb = chair.get_oriented_bounding_box()\nprint(obb)\ndraw([chair, obb])<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"432\" height=\"397\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-07U670.png\" alt=\"\" class=\"wp-image-2065\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-07U670.png 432w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-07U670-300x276.png 300w\" sizes=\"(max-width: 432px) 100vw, 432px\" \/><\/figure>\n\n\n\n<h2>7.\u51f8\u5305<\/h2>\n\n\n\n<p>o3d.geometry.Geometry3D \u63d0\u4f9b\u4e86 <strong>compute_convex_hull()<\/strong> \u65b9\u6cd5\uff0c\u6765\u83b7\u53d6\u70b9\u4e91\u7684\u51f8\u5305\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>def compute_convex_hull(self):\n    &quot;&quot;&quot;\n    Returns:\n        Tuple[open3d.geometry.TriangleMesh, List[int]] \u8fd4\u56de\u4e24\u4e2a\u503c\uff0c\u7b2c\u4e00\u4e2a\u4ee5\u4e09\u89d2\u5f62\u7f51\u683c\u8fd4\u56de\u51f8\u5305\uff0c\u7b2c\u4e8c\u4e2a\u8fd4\u56de\u51f8\u5305\u7684\u9876\u70b9\u4e0b\u6807\u3002\n    &quot;&quot;&quot;<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>hull, ind = chair.compute_convex_hull()\n\nhull.paint_uniform_color([1,0,0])\ndraw([hull, chair])<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"532\" height=\"397\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-VVZ070.png\" alt=\"\" class=\"wp-image-2067\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-VVZ070.png 532w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-VVZ070-300x224.png 300w\" sizes=\"(max-width: 532px) 100vw, 532px\" \/><\/figure>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>chair.paint_uniform_color([0.5,0.5,0.5])\npoints = chair.select_by_index(ind)  # \u7ea2\u8272\u70b9\u4e3a\u51f8\u5305\u9876\u70b9\npoints.paint_uniform_color([1,0,0])\ndraw([chair, points])<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"382\" height=\"376\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-KML770.png\" alt=\"\" class=\"wp-image-2068\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-KML770.png 382w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-KML770-300x295.png 300w\" sizes=\"(max-width: 382px) 100vw, 382px\" \/><\/figure>\n\n\n\n<h2>8. dbscan\u805a\u7c7b<\/h2>\n\n\n\n<p>open3d.geometry.PointCloud \u63d0\u4f9b\u4e86 <strong>cluster_dbscan(self, eps, min_points, print_progress=False)<\/strong> \u65b9\u6cd5\uff0c\u5b9e\u73b0dbscan\u5bc6\u5ea6\u805a\u7c7b\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>def cluster_dbscan(self, eps, min_points, print_progress=False):\n    &quot;&quot;&quot;\n    cluster_dbscan(self, eps, min_points, print_progress=False)        \n    Args:\n        eps (float):\u5bc6\u5ea6\n        min_points (int): \u5f62\u6210\u7c07\u7684\u6700\u5c0f\u70b9\u6570\n        print_progress (bool, optional, default=False): \n    Returns:\n        open3d.utility.IntVector label\u503c\uff0cint\n    &quot;&quot;&quot;<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>from matplotlib import pyplot as plt\nlabels = pcd.cluster_dbscan(eps=0.02, min_points=10, print_progress=True)\nlabels = np.asarray(labels)\nmax_label = labels.max()\ncolors = plt.get_cmap(&quot;tab20&quot;)(labels \/ (max_label if max_label &gt; 0 else 1))\ncolors[labels &lt; 0] = 0\npcd.colors = o3d.utility.Vector3dVector(colors[:, :3])\n\ndraw(pcd)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"455\" height=\"286\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-J9SB80.png\" alt=\"\" class=\"wp-image-2069\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-J9SB80.png 455w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-J9SB80-300x189.png 300w\" sizes=\"(max-width: 455px) 100vw, 455px\" \/><\/figure>\n\n\n\n<h2>9. \u5e73\u9762\u5206\u5272<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-plain\"><code>open3d.geometry.PointCloud \u63d0\u4f9b\u4e86 **segment_plane(self, distance_threshold, ransac_n, num_iterations)** \u65b9\u6cd5\uff0c\u901a\u8fc7RANSAC\u4ece\u70b9\u4e91\u4e2d\u5206\u5272\u5e73\u9762\u3002<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>def segment_plane(self, distance_threshold, ransac_n, num_iterations):\n    &quot;&quot;&quot;        \n    Args:\n        distance_threshold (float): \u70b9\u5230\u9762\u7684\u6700\u5927\u8ddd\u79bb\n        ransac_n (int): \u968f\u673a\u91c7\u6837\u4f30\u8ba1\u5e73\u9762\u7684\u70b9\u6570\n        num_iterations (int): \u8fed\u4ee3\u6b21\u6570\n\n    Returns:\n        Tuple[numpy.ndarray[float64[4, 1]], List[int]]\n        &quot;&quot;&quot;<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>pcd = o3d.io.read_point_cloud(&#39;datas\/fragment.ply&#39;)\nplane_model, ind = pcd.segment_plane(distance_threshold=0.01, ransac_n=3, num_iterations=1000)\n\nplane = pcd.select_by_index(ind)\nplane.paint_uniform_color([1,0,0])\nwithout_plane = pcd.select_by_index(ind, True)\ndraw([plane, without_plane])<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"471\" height=\"301\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-T48W70.png\" alt=\"\" class=\"wp-image-2070\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-T48W70.png 471w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-T48W70-300x192.png 300w\" sizes=\"(max-width: 471px) 100vw, 471px\" \/><\/figure>\n\n\n\n<h2>10. \u9690\u85cf\u70b9\u53bb\u9664<\/h2>\n\n\n\n<p>open3d.geometry.PointCloud \u63d0\u4f9b\u4e86 <strong>hidden_point_removal(self, camera_location, radius)<\/strong> \u65b9\u6cd5\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>def hidden_point_removal(self, camera_location, radius):\n    &quot;&quot;&quot;        \n    Args:\n        camera_location (numpy.ndarray[float64[3, 1]]): All points not visible from that location will be reomved\n        radius (float): The radius of the sperical projection\n\n    Returns:\n        Tuple[open3d.geometry.TriangleMesh, List[int]]\n    &quot;&quot;&quot;<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>diameter = np.linalg.norm(np.asarray(pcd.get_max_bound()) - np.asarray(pcd.get_min_bound()))\ncamera = [0, 0, diameter]\nradius = diameter * 100\n_, pt_map = pcd.hidden_point_removal(camera, radius)\n\npcd = pcd.select_by_index(pt_map)\ndraw(pcd)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"462\" height=\"232\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-4TJX70.png\" alt=\"\" class=\"wp-image-2071\" srcset=\"http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-4TJX70.png 462w, http:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-4TJX70-300x151.png 300w\" sizes=\"(max-width: 462px) 100vw, 462px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>open3d\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e13\u95e8\u7528\u4e8e\u70b9\u4e91\u7684\u6570\u636e\u7ed3\u6784 PointCloud\u3002 1.\u4f53\u7d20\u4e0b\u91c7\u6837 open3d.geome&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[22],"tags":[],"_links":{"self":[{"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2055"}],"collection":[{"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2055"}],"version-history":[{"count":9,"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2055\/revisions"}],"predecessor-version":[{"id":2154,"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2055\/revisions\/2154"}],"wp:attachment":[{"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2055"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}