{"id":2109,"date":"2021-08-12T10:38:29","date_gmt":"2021-08-12T02:38:29","guid":{"rendered":"http:\/\/www.yatenglg.cn\/?p=2109"},"modified":"2022-10-18T16:34:39","modified_gmt":"2022-10-18T08:34:39","slug":"open3d-kd%e6%a0%91%e5%8f%8a%e5%85%b6%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/www.yatenglg.cn\/blog\/?p=2109","title":{"rendered":"open3d-KD\u6811\u53ca\u5176\u64cd\u4f5c"},"content":{"rendered":"\n<h1>open3d\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7528\u4e8eKD\u6811\u7684\u6570\u636e\u7ed3\u6784 <strong>KDTreeFlann<\/strong>\u3002<\/h1>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>class KDTreeFlann(__pybind11_builtins.pybind11_object):\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.KDTreeFlann) -&gt; None\n        2. __init__(self: open3d.cpu.pybind.geometry.KDTreeFlann, data: numpy.ndarray[float64[m, n]]) -&gt; None\n        3. __init__(self: open3d.cpu.pybind.geometry.KDTreeFlann, geometry: open3d.cpu.pybind.geometry.Geometry) -&gt; None\n        4. __init__(self: open3d.cpu.pybind.geometry.KDTreeFlann, feature: open3d::pipelines::registration::Feature) -&gt; None\n        &quot;&quot;&quot;\n    # \u641c\u7d22\u6307\u5b9a\u534a\u5f84\u5185\u7684n\u4e2a\u70b9\n    def search_hybrid_vector_3d(self, query, radius, max_nn):\n    def search_hybrid_vector_xd(self, query, radius, max_nn):\n    # \u641c\u7d22\u6700\u8fd1\u7684n\u4e2a\u70b9\n    def search_knn_vector_3d(self, query, knn):\n    def search_knn_vector_xd(self, query, knn):\n    # \u641c\u7d22\u6307\u5b9a\u534a\u5f84\u5185\u7684\u6240\u6709\u70b9\n    def search_radius_vector_3d(self, query, radius):\n    def search_radius_vector_xd(self, query, radius):\n    # \u641c\u7d22\u70b9\u3002 \u9700\u6307\u5b9a\u641c\u7d22\u65b9\u5f0f\uff08\u8fd8\u662f\u4e0a\u9762\u90a3\u4e09\u79cd\uff09\n    def search_vector_3d(self, query, search_param):\n    def search_vector_xd(self, query, search_param): \n    def set_feature(self, feature):\n    def set_geometry(self, geometry):\n    def set_matrix_data(self, data):<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>import open3d as o3d\nimport numpy as np\nfrom open3d.visualization import draw_geometries\nfrom open3d.web_visualizer import draw<\/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(&quot;datas\/knot.ply&quot;)\nprint(pcd)\n-&gt; PointCloud with 1440 points.\nif not pcd.has_colors():\n    pcd.paint_uniform_color([0.5, 0.5, 0.5])\ndraw(pcd)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"444\" height=\"349\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-CDK870.png\" alt=\"\" class=\"wp-image-2114\" srcset=\"https:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-CDK870.png 444w, https:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-CDK870-300x236.png 300w\" sizes=\"(max-width: 444px) 100vw, 444px\" \/><\/figure>\n\n\n\n<h2>1. \u4ece\u70b9\u4e91\u6784\u5efakd\u6811<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>kdt = o3d.geometry.KDTreeFlann(pcd)\nprint(kdt)\n-&gt; &lt;open3d.cpu.pybind.geometry.KDTreeFlann object at 0x7eff65913a40&gt;<\/code><\/pre><\/div>\n\n\n\n<h2>2. \u67e5\u627e\u8fd1\u90bb\u70b9<\/h2>\n\n\n\n<h3>2.1 \u8bbe\u7f6e\u951a\u70b9\uff0c\u5c06\u7b2c300\u4e2a\u70b9\u989c\u8272\u8bbe\u7f6e\u4e3a\u7ea2\u8272\uff08\u51711440\u4e2a\u70b9\uff09<\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>pcd.colors[300] = [1, 0, 0]\ndraw(pcd)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"443\" height=\"349\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-NNT370.png\" alt=\"\" class=\"wp-image-2115\" srcset=\"https:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-NNT370.png 443w, https:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-NNT370-300x236.png 300w\" sizes=\"(max-width: 443px) 100vw, 443px\" \/><\/figure>\n\n\n\n<h3>2.2 \u67e5\u627e\u6700\u8fd1\u7684n\u4e2a\u70b9<\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>[k, ind, _] = kdt.search_knn_vector_3d(pcd.points[300], 50)\nnp.asarray(pcd.colors)[ind[1:]]=[0,1,0]\ndraw(pcd)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"493\" height=\"361\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-NT2470.png\" alt=\"\" class=\"wp-image-2116\" srcset=\"https:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-NT2470.png 493w, https:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-NT2470-300x220.png 300w\" sizes=\"(max-width: 493px) 100vw, 493px\" \/><\/figure>\n\n\n\n<h3>2.3 \u67e5\u627e\u6307\u5b9a\u534a\u5f84\u5185\u7684\u70b9<\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>[k, idx, _] = kdt.search_radius_vector_3d(pcd.points[300], 30)\nnp.asarray(pcd.colors)[idx[1:], :] = [0, 0, 1]\ndraw(pcd)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"475\" height=\"344\" src=\"http:\/\/www.yatenglg.cn\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-WDRW70.png\" alt=\"\" class=\"wp-image-2117\" srcset=\"https:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-WDRW70.png 475w, https:\/\/www.yatenglg.cn\/blog\/wp-content\/uploads\/2021\/08\/gnome-shell-screenshot-WDRW70-300x217.png 300w\" sizes=\"(max-width: 475px) 100vw, 475px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>open3d\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7528\u4e8eKD\u6811\u7684\u6570\u636e\u7ed3\u6784 KDTreeFlann\u3002 1. \u4ece\u70b9\u4e91\u6784\u5efakd\u6811 2. \u67e5\u627e\u8fd1\u90bb\u70b9&#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":"https:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2109"}],"collection":[{"href":"https:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2109"}],"version-history":[{"count":8,"href":"https:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2109\/revisions"}],"predecessor-version":[{"id":2152,"href":"https:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2109\/revisions\/2152"}],"wp:attachment":[{"href":"https:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}