Learning Open3D→Tutorial→基礎編→Pythonのインタフェース
Pythonのインタフェース
本節では、open3d
モジュールをimportする方法と、ヘルプ情報を表示する方法を示す。この時点で困ったことが置きた場合は、Setup Python binding environments.節を参照されたい。
注意 作業用(カレント)ディレクトリからみて2つ上にTestDataディレクトリがあり、その下にあるICPディレクトリの中にcloud_bin_0.pcd
ファイルがあることを仮定している。もしもそうなっていないのなら、。Open3D_examples.zipをダウンロードし、展開しておく。そして以下を実行する。
cd examples/Python/Basic
Jupyter notebookを使っている場合は、次のようにしてカレントディレクトリを確認しておこう
import os
os.getcwd()
'/mnt/disk/sirai/2020/Open3D-master'
そして、上記の想定と違っている場合は次のようにして、カレントディレクトリを適切にセットする(それぞれの環境に合わせたコマンドを実行すること)
os.listdir('.') # カレントディレクトリの内容の表示
['LICENSE', '3rdparty', '.clang-format', 'src', 'examples', 'CMakeLists.txt', 'Open3D_examples.zip', 'README.md', '.travis.yml', '.github', '.style.yapf', '.gitmodules', '.gitignore', '.appveyor.yml', 'CHANGELOG.md', 'util', 'docs']
os.chdir('examples/Python/Basic') # カレントディレクトリの移動
次のコード(プログラム)は2つの関数example_import_function
とexample_help_function
を定義している。これはOpen3DのPythonモジュールのごく基本的な使い方を示すものである。
# examples/Python/Basic/python_binding.py
import open3d as o3d
def example_import_function():
pcd = o3d.io.read_point_cloud("../../TestData/ICP/cloud_bin_0.pcd")
print(pcd)
def example_help_function():
help(o3d)
help(o3d.geometry.PointCloud)
help(o3d.io.read_point_cloud)
if __name__ == "__main__":
example_import_function()
example_help_function()
geometry::PointCloud with 198835 points. Help on package open3d: NAME open3d DESCRIPTION # ---------------------------------------------------------------------------- # - Open3D: www.open3d.org - # ---------------------------------------------------------------------------- # The MIT License (MIT) # # Copyright (c) 2018 www.open3d.org # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. # ---------------------------------------------------------------------------- PACKAGE CONTENTS j_visualizer open3d SUBMODULES camera color_map geometry integration io odometry registration utility visualization VERSION 0.9.0.0 FILE /opt/anaconda3/lib/python3.6/site-packages/open3d/__init__.py Help on class PointCloud in module open3d.open3d.geometry: class PointCloud(Geometry3D) | PointCloud class. A point cloud consists of point coordinates, and optionally point colors and point normals. | | Method resolution order: | PointCloud | Geometry3D | Geometry | pybind11_builtins.pybind11_object | builtins.object | | Methods defined here: | | __add__(...) | __add__(self: open3d.open3d.geometry.PointCloud, arg0: open3d.open3d.geometry.PointCloud) -> open3d.open3d.geometry.PointCloud | | __copy__(...) | __copy__(self: open3d.open3d.geometry.PointCloud) -> open3d.open3d.geometry.PointCloud | | __deepcopy__(...) | __deepcopy__(self: open3d.open3d.geometry.PointCloud, arg0: dict) -> open3d.open3d.geometry.PointCloud | | __iadd__(...) | __iadd__(self: open3d.open3d.geometry.PointCloud, arg0: open3d.open3d.geometry.PointCloud) -> open3d.open3d.geometry.PointCloud | | __init__(...) | __init__(*args, **kwargs) | Overloaded function. | | 1. __init__(self: open3d.open3d.geometry.PointCloud) -> None | | Default constructor | | 2. __init__(self: open3d.open3d.geometry.PointCloud, arg0: open3d.open3d.geometry.PointCloud) -> None | | Copy constructor | | 3. __init__(self: open3d.open3d.geometry.PointCloud, points: open3d.open3d.utility.Vector3dVector) -> None | | Create a PointCloud from points | | __repr__(...) | __repr__(self: open3d.open3d.geometry.PointCloud) -> str | | cluster_dbscan(...) | cluster_dbscan(self, eps, min_points, print_progress=False) | | Cluster PointCloud using the DBSCAN algorithm Ester et al., 'A Density-Based Algorithm for Discovering Clusters in Large Spatial Databases with Noise', 1996. Returns a list of point labels, -1 indicates noise according to the algorithm. | | Args: | eps (float): Density parameter that is used to find neighbouring points. | min_points (int): Minimum number of points to form a cluster. | print_progress (bool, optional, default=False): If true the progress is visualized in the console. | | Returns: | open3d.utility.IntVector | | compute_convex_hull(...) | compute_convex_hull(self) | | Computes the convex hull of the point cloud. | | Returns: | Tuple[open3d.geometry.TriangleMesh, List[int]] | | compute_mahalanobis_distance(...) | compute_mahalanobis_distance(self) | | Function to compute the Mahalanobis distance for points in a point cloud. See: https://en.wikipedia.org/wiki/Mahalanobis_distance. | | Returns: | open3d.utility.DoubleVector | | compute_mean_and_covariance(...) | compute_mean_and_covariance(self) | | Function to compute the mean and covariance matrix of a point cloud. | | Returns: | Tuple[numpy.ndarray[float64[3, 1]], numpy.ndarray[float64[3, 3]]] | | compute_nearest_neighbor_distance(...) | compute_nearest_neighbor_distance(self) | | Function to compute the distance from a point to its nearest neighbor in the point cloud | | Returns: | open3d.utility.DoubleVector | | compute_point_cloud_distance(...) | compute_point_cloud_distance(self, target) | | For each point in the source point cloud, compute the distance to the target point cloud. | | Args: | target (open3d.geometry.PointCloud): The target point cloud. | | Returns: | open3d.utility.DoubleVector | | crop(...) | crop(bounding_box, bounding_box) | | Function to crop input pointcloud into output pointcloud | | Args: | bounding_box (open3d.geometry.AxisAlignedBoundingBox) ): AxisAlignedBoundingBox to crop points | bounding_box (open3d.geometry.OrientedBoundingBox): AxisAlignedBoundingBox to crop points | | Returns: | open3d.geometry.PointCloud | | estimate_normals(...) | estimate_normals(self, search_param=geometry::KDTreeSearchParamKNN with knn = 30, fast_normal_computation=True) | | Function to compute the normals of a point cloud. Normals are oriented with respect to the input point cloud if normals exist | | Args: | search_param (open3d.geometry.KDTreeSearchParam, optional, default=geometry::KDTreeSearchParamKNN with knn = 30): The KDTree search parameters for neighborhood search. | fast_normal_computation (bool, optional, default=True): If true, the normal estiamtion uses a non-iterative method to extract the eigenvector from the covariance matrix. This is faster, but is not as numerical stable. | | Returns: | bool | | has_colors(...) | has_colors(self) | | Returns ``True`` if the point cloud contains point colors. | | Returns: | bool | | has_normals(...) | has_normals(self) | | Returns ``True`` if the point cloud contains point normals. | | Returns: | bool | | has_points(...) | has_points(self) | | Returns ``True`` if the point cloud contains points. | | Returns: | bool | | hidden_point_removal(...) | hidden_point_removal(self, camera_location, radius) | | Removes hidden points from a point cloud and returns a mesh of the remaining points. Based on Katz et al. 'Direct Visibility of Point Sets', 2007. | | Args: | camera_location (numpy.ndarray[float64[3, 1]]): All points not visible from that location will be reomved | radius (float): The radius of the sperical projection | | Returns: | Tuple[open3d.geometry.TriangleMesh, List[int]] | | normalize_normals(...) | normalize_normals(self) | | Normalize point normals to length 1. | | Returns: | open3d.geometry.PointCloud | | orient_normals_to_align_with_direction(...) | orient_normals_to_align_with_direction(self, orientation_reference=array([0., 0., 1.])) | | Function to orient the normals of a point cloud | | Args: | orientation_reference (numpy.ndarray[float64[3, 1]], optional, default=array([0., 0., 1.])): Normals are oriented with respect to orientation_reference. | | Returns: | bool | | orient_normals_towards_camera_location(...) | orient_normals_towards_camera_location(self, camera_location=array([0., 0., 0.])) | | Function to orient the normals of a point cloud | | Args: | camera_location (numpy.ndarray[float64[3, 1]], optional, default=array([0., 0., 0.])): Normals are oriented with towards the camera_location. | | Returns: | bool | | paint_uniform_color(...) | paint_uniform_color(self, color) | | Assigns each point in the PointCloud the same color. | | Args: | color (numpy.ndarray[float64[3, 1]]): RGB color for the PointCloud. | | Returns: | open3d.geometry.PointCloud | | remove_none_finite_points(...) | remove_none_finite_points(self, remove_nan=True, remove_infinite=True) | | Function to remove none-finite points from the PointCloud | | Args: | remove_nan (bool, optional, default=True): Remove NaN values from the PointCloud | remove_infinite (bool, optional, default=True): Remove infinite values from the PointCloud | | Returns: | open3d.geometry.PointCloud | | remove_radius_outlier(...) | remove_radius_outlier(self, nb_points, radius) | | Function to remove points that have less than nb_points in a given sphere of a given radius | | Args: | nb_points (int): Number of points within the radius. | radius (float): Radius of the sphere. | | Returns: | Tuple[open3d.geometry.PointCloud, List[int]] | | remove_statistical_outlier(...) | remove_statistical_outlier(self, nb_neighbors, std_ratio) | | Function to remove points that are further away from their neighbors in average | | Args: | nb_neighbors (int): Number of neighbors around the target point. | std_ratio (float): Standard deviation ratio. | | Returns: | Tuple[open3d.geometry.PointCloud, List[int]] | | segment_plane(...) | segment_plane(self, distance_threshold, ransac_n, num_iterations) | | Segments a plane in the point cloud using the RANSAC algorithm. | | Args: | distance_threshold (float): Max distance a point can be from the plane model, and still be considered an inlier. | ransac_n (int): Number of initial points to be considered inliers in each iteration. | num_iterations (int): Number of iterations. | | Returns: | Tuple[numpy.ndarray[float64[4, 1]], List[int]] | | select_down_sample(...) | select_down_sample(self, indices, invert=False) | | Function to select points from input pointcloud into output pointcloud. ``indices``: Indices of points to be selected. ``invert``: Set to ``True`` to invert the selection of indices. | | Args: | indices (List[int]): Indices of points to be selected. | invert (bool, optional, default=False): Set to ``True`` to invert the selection of indices. | | Returns: | open3d.geometry.PointCloud | | uniform_down_sample(...) | uniform_down_sample(self, every_k_points) | | Function to downsample input pointcloud into output pointcloud uniformly. The sample is performed in the order of the points with the 0-th point always chosen, not at random. | | Args: | every_k_points (int): Sample rate, the selected point indices are [0, k, 2k, ...] | | Returns: | open3d.geometry.PointCloud | | voxel_down_sample(...) | voxel_down_sample(self, voxel_size) | | Function to downsample input pointcloud into output pointcloud with a voxel | | Args: | voxel_size (float): Voxel size to downsample into. | | Returns: | open3d.geometry.PointCloud | | voxel_down_sample_and_trace(...) | voxel_down_sample_and_trace(self, voxel_size, min_bound, max_bound, approximate_class=False) | | Function to downsample using geometry.PointCloud.VoxelDownSample also records point cloud index before downsampling | | Args: | voxel_size (float): Voxel size to downsample into. | min_bound (numpy.ndarray[float64[3, 1]]): Minimum coordinate of voxel boundaries | max_bound (numpy.ndarray[float64[3, 1]]): Maximum coordinate of voxel boundaries | approximate_class (bool, optional, default=False) | | Returns: | Tuple[open3d.geometry.PointCloud, numpy.ndarray[int32[m, n]]] | | ---------------------------------------------------------------------- | Static methods defined here: | | create_from_depth_image(...) from builtins.PyCapsule | create_from_depth_image(depth, intrinsic, extrinsic=(with default value), depth_scale=1000.0, depth_trunc=1000.0, stride=1) | | Factory function to create a pointcloud from a depth image and a | camera. Given depth value d at (u, v) image coordinate, the corresponding 3d | point is: | | - z = d / depth_scale | - x = (u - cx) * z / fx | - y = (v - cy) * z / fy | | Args: | depth (open3d.geometry.Image) | intrinsic (open3d.camera.PinholeCameraIntrinsic) | extrinsic (numpy.ndarray[float64[4, 4]], optional) Default value: | | array([[1., 0., 0., 0.], | [0., 1., 0., 0.], | [0., 0., 1., 0.], | [0., 0., 0., 1.]]) | depth_scale (float, optional, default=1000.0) | depth_trunc (float, optional, default=1000.0) | stride (int, optional, default=1) | | Returns: | open3d.geometry.PointCloud | | create_from_rgbd_image(...) from builtins.PyCapsule | create_from_rgbd_image(image, intrinsic, extrinsic=(with default value)) | | Factory function to create a pointcloud from an RGB-D image and a | camera. Given depth value d at (u, v) image coordinate, the corresponding 3d | point is: | | - z = d / depth_scale | - x = (u - cx) * z / fx | - y = (v - cy) * z / fy | | Args: | image (open3d.geometry.RGBDImage) | intrinsic (open3d.camera.PinholeCameraIntrinsic) | extrinsic (numpy.ndarray[float64[4, 4]], optional) Default value: | | array([[1., 0., 0., 0.], | [0., 1., 0., 0.], | [0., 0., 1., 0.], | [0., 0., 0., 1.]]) | | Returns: | open3d.geometry.PointCloud | | ---------------------------------------------------------------------- | Data descriptors defined here: | | colors | ``float64`` array of shape ``(num_points, 3)``, range ``[0, 1]`` , use ``numpy.asarray()`` to access data: RGB colors of points. | | normals | ``float64`` array of shape ``(num_points, 3)``, use ``numpy.asarray()`` to access data: Points normals. | | points | ``float64`` array of shape ``(num_points, 3)``, use ``numpy.asarray()`` to access data: Points coordinates. | | ---------------------------------------------------------------------- | Methods inherited from Geometry3D: | | get_axis_aligned_bounding_box(...) | get_axis_aligned_bounding_box(self) | | Returns an axis-aligned bounding box of the geometry. | | Returns: | open3d.geometry.AxisAlignedBoundingBox | | get_center(...) | get_center(self) | | Returns the center of the geometry coordinates. | | Returns: | numpy.ndarray[float64[3, 1]] | | get_max_bound(...) | get_max_bound(self) | | Returns max bounds for geometry coordinates. | | Returns: | numpy.ndarray[float64[3, 1]] | | get_min_bound(...) | get_min_bound(self) | | Returns min bounds for geometry coordinates. | | Returns: | numpy.ndarray[float64[3, 1]] | | get_oriented_bounding_box(...) | get_oriented_bounding_box(self) | | Returns an oriented bounding box of the geometry. | | Returns: | open3d.geometry.OrientedBoundingBox | | rotate(...) | rotate(self, R, center=True) | | Apply rotation to the geometry coordinates and normals. | | Args: | R (numpy.ndarray[float64[3, 3]]): The rotation matrix | center (bool, optional, default=True): If true, then the rotation is applied to the centered geometry | | Returns: | open3d.geometry.Geometry3D | | scale(...) | scale(self, scale, center=True) | | Apply scaling to the geometry coordinates. | | Args: | scale (float): The scale parameter that is multiplied to the points/vertices of the geometry | center (bool, optional, default=True): If true, then the scale is applied to the centered geometry | | Returns: | open3d.geometry.Geometry3D | | transform(...) | transform(self, arg0) | | Apply transformation (4x4 matrix) to the geometry coordinates. | | Args: | arg0 (numpy.ndarray[float64[4, 4]]) | | Returns: | open3d.geometry.Geometry3D | | translate(...) | translate(self, translation, relative=True) | | Apply translation to the geometry coordinates. | | Args: | translation (numpy.ndarray[float64[3, 1]]): A 3D vector to transform the geometry | relative (bool, optional, default=True): If true, the translation vector is directly added to the geometry coordinates. Otherwise, the center is moved to the translation vector. | | Returns: | open3d.geometry.Geometry3D | | ---------------------------------------------------------------------- | Static methods inherited from Geometry3D: | | get_rotation_matrix_from_axis_angle(...) from builtins.PyCapsule | get_rotation_matrix_from_axis_angle(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_quaternion(...) from builtins.PyCapsule | get_rotation_matrix_from_quaternion(rotation: numpy.ndarray[float64[4, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_xyz(...) from builtins.PyCapsule | get_rotation_matrix_from_xyz(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_xzy(...) from builtins.PyCapsule | get_rotation_matrix_from_xzy(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_yxz(...) from builtins.PyCapsule | get_rotation_matrix_from_yxz(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_yzx(...) from builtins.PyCapsule | get_rotation_matrix_from_yzx(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_zxy(...) from builtins.PyCapsule | get_rotation_matrix_from_zxy(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_zyx(...) from builtins.PyCapsule | get_rotation_matrix_from_zyx(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | ---------------------------------------------------------------------- | Methods inherited from Geometry: | | clear(...) | clear(self) | | Clear all elements in the geometry. | | Returns: | open3d.geometry.Geometry | | dimension(...) | dimension(self) | | Returns whether the geometry is 2D or 3D. | | Returns: | int | | get_geometry_type(...) | get_geometry_type(self) | | Returns one of registered geometry types. | | Returns: | open3d.geometry.Geometry.GeometryType | | is_empty(...) | is_empty(self) | | Returns ``True`` iff the geometry is empty. | | Returns: | bool | | ---------------------------------------------------------------------- | Data and other attributes inherited from Geometry: | | HalfEdgeTriangleMesh = Type.HalfEdgeTriangleMesh | | Image = Type.Image | | LineSet = Type.LineSet | | PointCloud = Type.PointCloud | | RGBDImage = Type.RGBDImage | | TetraMesh = Type.TetraMesh | | TriangleMesh = Type.TriangleMesh | | Type = <class 'open3d.open3d.geometry.Geometry.Type'> | Enum class for Geometry types. | | Unspecified = Type.Unspecified | | VoxelGrid = Type.VoxelGrid | | ---------------------------------------------------------------------- | Methods inherited from pybind11_builtins.pybind11_object: | | __new__(*args, **kwargs) from pybind11_builtins.pybind11_type | Create and return a new object. See help(type) for accurate signature. Help on built-in function read_point_cloud in module open3d.open3d.io: read_point_cloud(...) method of builtins.PyCapsule instance read_point_cloud(filename, format='auto', remove_nan_points=True, remove_infinite_points=True, print_progress=False) Function to read PointCloud from file Args: filename (str): Path to file. format (str, optional, default='auto'): The format of the input file. When not specified or set as ``auto``, the format is inferred from file extension name. remove_nan_points (bool, optional, default=True): If true, all points that include a NaN are removed from the PointCloud. remove_infinite_points (bool, optional, default=True): If true, all points that include an infinite value are removed from the PointCloud. print_progress (bool, optional, default=False): If set to true a progress bar is visualized in the console Returns: open3d.geometry.PointCloud
example_import_function
関数の中で使われているread_point_cloud
関数は、ポイントクラウド(点群)ファイルを読み込み、PointCloud
クラスのインスタンスを返す。
import open3d as o3d
def example_import_function():
pcd = o3d.io.read_point_cloud("../../TestData/ICP/cloud_bin_0.pcd")
print(pcd)
example_import_function()
geometry::PointCloud with 198835 points.
Pythonの組み込み関数help
を用いてOpen3Dの関数やクラスの定義や使い方を調べるのはお勧めである。例えば:
def example_help_function():
help(o3d)
help(o3d.geometry.PointCloud)
help(o3d.io.read_point_cloud)
example_help_function
関数の中で呼ばれているhelp
関数はPython言語の組み込み関数で、Open3Dの関数やクラスの説明を表示してくれるものである。
例えば次のようにすれば、Open3Dモジュールについての概要が表示される:
# 注意: 先に import open3d as o3d としたので
# help(open3d)は使えない
help(o3d)
Help on package open3d: NAME open3d DESCRIPTION # ---------------------------------------------------------------------------- # - Open3D: www.open3d.org - # ---------------------------------------------------------------------------- # The MIT License (MIT) # # Copyright (c) 2018 www.open3d.org # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. # ---------------------------------------------------------------------------- PACKAGE CONTENTS j_visualizer open3d SUBMODULES camera color_map geometry integration io odometry registration utility visualization VERSION 0.9.0.0 FILE /opt/anaconda3/lib/python3.6/site-packages/open3d/__init__.py
help(o3d.geometry.PointCloud)
はPointCloud
クラスの説明を返す:
help(o3d.geometry.PointCloud)
Help on class PointCloud in module open3d.open3d.geometry: class PointCloud(Geometry3D) | PointCloud class. A point cloud consists of point coordinates, and optionally point colors and point normals. | | Method resolution order: | PointCloud | Geometry3D | Geometry | pybind11_builtins.pybind11_object | builtins.object | | Methods defined here: | | __add__(...) | __add__(self: open3d.open3d.geometry.PointCloud, arg0: open3d.open3d.geometry.PointCloud) -> open3d.open3d.geometry.PointCloud | | __copy__(...) | __copy__(self: open3d.open3d.geometry.PointCloud) -> open3d.open3d.geometry.PointCloud | | __deepcopy__(...) | __deepcopy__(self: open3d.open3d.geometry.PointCloud, arg0: dict) -> open3d.open3d.geometry.PointCloud | | __iadd__(...) | __iadd__(self: open3d.open3d.geometry.PointCloud, arg0: open3d.open3d.geometry.PointCloud) -> open3d.open3d.geometry.PointCloud | | __init__(...) | __init__(*args, **kwargs) | Overloaded function. | | 1. __init__(self: open3d.open3d.geometry.PointCloud) -> None | | Default constructor | | 2. __init__(self: open3d.open3d.geometry.PointCloud, arg0: open3d.open3d.geometry.PointCloud) -> None | | Copy constructor | | 3. __init__(self: open3d.open3d.geometry.PointCloud, points: open3d.open3d.utility.Vector3dVector) -> None | | Create a PointCloud from points | | __repr__(...) | __repr__(self: open3d.open3d.geometry.PointCloud) -> str | | cluster_dbscan(...) | cluster_dbscan(self, eps, min_points, print_progress=False) | | Cluster PointCloud using the DBSCAN algorithm Ester et al., 'A Density-Based Algorithm for Discovering Clusters in Large Spatial Databases with Noise', 1996. Returns a list of point labels, -1 indicates noise according to the algorithm. | | Args: | eps (float): Density parameter that is used to find neighbouring points. | min_points (int): Minimum number of points to form a cluster. | print_progress (bool, optional, default=False): If true the progress is visualized in the console. | | Returns: | open3d.utility.IntVector | | compute_convex_hull(...) | compute_convex_hull(self) | | Computes the convex hull of the point cloud. | | Returns: | Tuple[open3d.geometry.TriangleMesh, List[int]] | | compute_mahalanobis_distance(...) | compute_mahalanobis_distance(self) | | Function to compute the Mahalanobis distance for points in a point cloud. See: https://en.wikipedia.org/wiki/Mahalanobis_distance. | | Returns: | open3d.utility.DoubleVector | | compute_mean_and_covariance(...) | compute_mean_and_covariance(self) | | Function to compute the mean and covariance matrix of a point cloud. | | Returns: | Tuple[numpy.ndarray[float64[3, 1]], numpy.ndarray[float64[3, 3]]] | | compute_nearest_neighbor_distance(...) | compute_nearest_neighbor_distance(self) | | Function to compute the distance from a point to its nearest neighbor in the point cloud | | Returns: | open3d.utility.DoubleVector | | compute_point_cloud_distance(...) | compute_point_cloud_distance(self, target) | | For each point in the source point cloud, compute the distance to the target point cloud. | | Args: | target (open3d.geometry.PointCloud): The target point cloud. | | Returns: | open3d.utility.DoubleVector | | crop(...) | crop(bounding_box, bounding_box) | | Function to crop input pointcloud into output pointcloud | | Args: | bounding_box (open3d.geometry.AxisAlignedBoundingBox) ): AxisAlignedBoundingBox to crop points | bounding_box (open3d.geometry.OrientedBoundingBox): AxisAlignedBoundingBox to crop points | | Returns: | open3d.geometry.PointCloud | | estimate_normals(...) | estimate_normals(self, search_param=geometry::KDTreeSearchParamKNN with knn = 30, fast_normal_computation=True) | | Function to compute the normals of a point cloud. Normals are oriented with respect to the input point cloud if normals exist | | Args: | search_param (open3d.geometry.KDTreeSearchParam, optional, default=geometry::KDTreeSearchParamKNN with knn = 30): The KDTree search parameters for neighborhood search. | fast_normal_computation (bool, optional, default=True): If true, the normal estiamtion uses a non-iterative method to extract the eigenvector from the covariance matrix. This is faster, but is not as numerical stable. | | Returns: | bool | | has_colors(...) | has_colors(self) | | Returns ``True`` if the point cloud contains point colors. | | Returns: | bool | | has_normals(...) | has_normals(self) | | Returns ``True`` if the point cloud contains point normals. | | Returns: | bool | | has_points(...) | has_points(self) | | Returns ``True`` if the point cloud contains points. | | Returns: | bool | | hidden_point_removal(...) | hidden_point_removal(self, camera_location, radius) | | Removes hidden points from a point cloud and returns a mesh of the remaining points. Based on Katz et al. 'Direct Visibility of Point Sets', 2007. | | Args: | camera_location (numpy.ndarray[float64[3, 1]]): All points not visible from that location will be reomved | radius (float): The radius of the sperical projection | | Returns: | Tuple[open3d.geometry.TriangleMesh, List[int]] | | normalize_normals(...) | normalize_normals(self) | | Normalize point normals to length 1. | | Returns: | open3d.geometry.PointCloud | | orient_normals_to_align_with_direction(...) | orient_normals_to_align_with_direction(self, orientation_reference=array([0., 0., 1.])) | | Function to orient the normals of a point cloud | | Args: | orientation_reference (numpy.ndarray[float64[3, 1]], optional, default=array([0., 0., 1.])): Normals are oriented with respect to orientation_reference. | | Returns: | bool | | orient_normals_towards_camera_location(...) | orient_normals_towards_camera_location(self, camera_location=array([0., 0., 0.])) | | Function to orient the normals of a point cloud | | Args: | camera_location (numpy.ndarray[float64[3, 1]], optional, default=array([0., 0., 0.])): Normals are oriented with towards the camera_location. | | Returns: | bool | | paint_uniform_color(...) | paint_uniform_color(self, color) | | Assigns each point in the PointCloud the same color. | | Args: | color (numpy.ndarray[float64[3, 1]]): RGB color for the PointCloud. | | Returns: | open3d.geometry.PointCloud | | remove_none_finite_points(...) | remove_none_finite_points(self, remove_nan=True, remove_infinite=True) | | Function to remove none-finite points from the PointCloud | | Args: | remove_nan (bool, optional, default=True): Remove NaN values from the PointCloud | remove_infinite (bool, optional, default=True): Remove infinite values from the PointCloud | | Returns: | open3d.geometry.PointCloud | | remove_radius_outlier(...) | remove_radius_outlier(self, nb_points, radius) | | Function to remove points that have less than nb_points in a given sphere of a given radius | | Args: | nb_points (int): Number of points within the radius. | radius (float): Radius of the sphere. | | Returns: | Tuple[open3d.geometry.PointCloud, List[int]] | | remove_statistical_outlier(...) | remove_statistical_outlier(self, nb_neighbors, std_ratio) | | Function to remove points that are further away from their neighbors in average | | Args: | nb_neighbors (int): Number of neighbors around the target point. | std_ratio (float): Standard deviation ratio. | | Returns: | Tuple[open3d.geometry.PointCloud, List[int]] | | segment_plane(...) | segment_plane(self, distance_threshold, ransac_n, num_iterations) | | Segments a plane in the point cloud using the RANSAC algorithm. | | Args: | distance_threshold (float): Max distance a point can be from the plane model, and still be considered an inlier. | ransac_n (int): Number of initial points to be considered inliers in each iteration. | num_iterations (int): Number of iterations. | | Returns: | Tuple[numpy.ndarray[float64[4, 1]], List[int]] | | select_down_sample(...) | select_down_sample(self, indices, invert=False) | | Function to select points from input pointcloud into output pointcloud. ``indices``: Indices of points to be selected. ``invert``: Set to ``True`` to invert the selection of indices. | | Args: | indices (List[int]): Indices of points to be selected. | invert (bool, optional, default=False): Set to ``True`` to invert the selection of indices. | | Returns: | open3d.geometry.PointCloud | | uniform_down_sample(...) | uniform_down_sample(self, every_k_points) | | Function to downsample input pointcloud into output pointcloud uniformly. The sample is performed in the order of the points with the 0-th point always chosen, not at random. | | Args: | every_k_points (int): Sample rate, the selected point indices are [0, k, 2k, ...] | | Returns: | open3d.geometry.PointCloud | | voxel_down_sample(...) | voxel_down_sample(self, voxel_size) | | Function to downsample input pointcloud into output pointcloud with a voxel | | Args: | voxel_size (float): Voxel size to downsample into. | | Returns: | open3d.geometry.PointCloud | | voxel_down_sample_and_trace(...) | voxel_down_sample_and_trace(self, voxel_size, min_bound, max_bound, approximate_class=False) | | Function to downsample using geometry.PointCloud.VoxelDownSample also records point cloud index before downsampling | | Args: | voxel_size (float): Voxel size to downsample into. | min_bound (numpy.ndarray[float64[3, 1]]): Minimum coordinate of voxel boundaries | max_bound (numpy.ndarray[float64[3, 1]]): Maximum coordinate of voxel boundaries | approximate_class (bool, optional, default=False) | | Returns: | Tuple[open3d.geometry.PointCloud, numpy.ndarray[int32[m, n]]] | | ---------------------------------------------------------------------- | Static methods defined here: | | create_from_depth_image(...) from builtins.PyCapsule | create_from_depth_image(depth, intrinsic, extrinsic=(with default value), depth_scale=1000.0, depth_trunc=1000.0, stride=1) | | Factory function to create a pointcloud from a depth image and a | camera. Given depth value d at (u, v) image coordinate, the corresponding 3d | point is: | | - z = d / depth_scale | - x = (u - cx) * z / fx | - y = (v - cy) * z / fy | | Args: | depth (open3d.geometry.Image) | intrinsic (open3d.camera.PinholeCameraIntrinsic) | extrinsic (numpy.ndarray[float64[4, 4]], optional) Default value: | | array([[1., 0., 0., 0.], | [0., 1., 0., 0.], | [0., 0., 1., 0.], | [0., 0., 0., 1.]]) | depth_scale (float, optional, default=1000.0) | depth_trunc (float, optional, default=1000.0) | stride (int, optional, default=1) | | Returns: | open3d.geometry.PointCloud | | create_from_rgbd_image(...) from builtins.PyCapsule | create_from_rgbd_image(image, intrinsic, extrinsic=(with default value)) | | Factory function to create a pointcloud from an RGB-D image and a | camera. Given depth value d at (u, v) image coordinate, the corresponding 3d | point is: | | - z = d / depth_scale | - x = (u - cx) * z / fx | - y = (v - cy) * z / fy | | Args: | image (open3d.geometry.RGBDImage) | intrinsic (open3d.camera.PinholeCameraIntrinsic) | extrinsic (numpy.ndarray[float64[4, 4]], optional) Default value: | | array([[1., 0., 0., 0.], | [0., 1., 0., 0.], | [0., 0., 1., 0.], | [0., 0., 0., 1.]]) | | Returns: | open3d.geometry.PointCloud | | ---------------------------------------------------------------------- | Data descriptors defined here: | | colors | ``float64`` array of shape ``(num_points, 3)``, range ``[0, 1]`` , use ``numpy.asarray()`` to access data: RGB colors of points. | | normals | ``float64`` array of shape ``(num_points, 3)``, use ``numpy.asarray()`` to access data: Points normals. | | points | ``float64`` array of shape ``(num_points, 3)``, use ``numpy.asarray()`` to access data: Points coordinates. | | ---------------------------------------------------------------------- | Methods inherited from Geometry3D: | | get_axis_aligned_bounding_box(...) | get_axis_aligned_bounding_box(self) | | Returns an axis-aligned bounding box of the geometry. | | Returns: | open3d.geometry.AxisAlignedBoundingBox | | get_center(...) | get_center(self) | | Returns the center of the geometry coordinates. | | Returns: | numpy.ndarray[float64[3, 1]] | | get_max_bound(...) | get_max_bound(self) | | Returns max bounds for geometry coordinates. | | Returns: | numpy.ndarray[float64[3, 1]] | | get_min_bound(...) | get_min_bound(self) | | Returns min bounds for geometry coordinates. | | Returns: | numpy.ndarray[float64[3, 1]] | | get_oriented_bounding_box(...) | get_oriented_bounding_box(self) | | Returns an oriented bounding box of the geometry. | | Returns: | open3d.geometry.OrientedBoundingBox | | rotate(...) | rotate(self, R, center=True) | | Apply rotation to the geometry coordinates and normals. | | Args: | R (numpy.ndarray[float64[3, 3]]): The rotation matrix | center (bool, optional, default=True): If true, then the rotation is applied to the centered geometry | | Returns: | open3d.geometry.Geometry3D | | scale(...) | scale(self, scale, center=True) | | Apply scaling to the geometry coordinates. | | Args: | scale (float): The scale parameter that is multiplied to the points/vertices of the geometry | center (bool, optional, default=True): If true, then the scale is applied to the centered geometry | | Returns: | open3d.geometry.Geometry3D | | transform(...) | transform(self, arg0) | | Apply transformation (4x4 matrix) to the geometry coordinates. | | Args: | arg0 (numpy.ndarray[float64[4, 4]]) | | Returns: | open3d.geometry.Geometry3D | | translate(...) | translate(self, translation, relative=True) | | Apply translation to the geometry coordinates. | | Args: | translation (numpy.ndarray[float64[3, 1]]): A 3D vector to transform the geometry | relative (bool, optional, default=True): If true, the translation vector is directly added to the geometry coordinates. Otherwise, the center is moved to the translation vector. | | Returns: | open3d.geometry.Geometry3D | | ---------------------------------------------------------------------- | Static methods inherited from Geometry3D: | | get_rotation_matrix_from_axis_angle(...) from builtins.PyCapsule | get_rotation_matrix_from_axis_angle(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_quaternion(...) from builtins.PyCapsule | get_rotation_matrix_from_quaternion(rotation: numpy.ndarray[float64[4, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_xyz(...) from builtins.PyCapsule | get_rotation_matrix_from_xyz(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_xzy(...) from builtins.PyCapsule | get_rotation_matrix_from_xzy(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_yxz(...) from builtins.PyCapsule | get_rotation_matrix_from_yxz(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_yzx(...) from builtins.PyCapsule | get_rotation_matrix_from_yzx(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_zxy(...) from builtins.PyCapsule | get_rotation_matrix_from_zxy(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | get_rotation_matrix_from_zyx(...) from builtins.PyCapsule | get_rotation_matrix_from_zyx(rotation: numpy.ndarray[float64[3, 1]]) -> numpy.ndarray[float64[3, 3]] | | ---------------------------------------------------------------------- | Methods inherited from Geometry: | | clear(...) | clear(self) | | Clear all elements in the geometry. | | Returns: | open3d.geometry.Geometry | | dimension(...) | dimension(self) | | Returns whether the geometry is 2D or 3D. | | Returns: | int | | get_geometry_type(...) | get_geometry_type(self) | | Returns one of registered geometry types. | | Returns: | open3d.geometry.Geometry.GeometryType | | is_empty(...) | is_empty(self) | | Returns ``True`` iff the geometry is empty. | | Returns: | bool | | ---------------------------------------------------------------------- | Data and other attributes inherited from Geometry: | | HalfEdgeTriangleMesh = Type.HalfEdgeTriangleMesh | | Image = Type.Image | | LineSet = Type.LineSet | | PointCloud = Type.PointCloud | | RGBDImage = Type.RGBDImage | | TetraMesh = Type.TetraMesh | | TriangleMesh = Type.TriangleMesh | | Type = <class 'open3d.open3d.geometry.Geometry.Type'> | Enum class for Geometry types. | | Unspecified = Type.Unspecified | | VoxelGrid = Type.VoxelGrid | | ---------------------------------------------------------------------- | Methods inherited from pybind11_builtins.pybind11_object: | | __new__(*args, **kwargs) from pybind11_builtins.pybind11_type | Create and return a new object. See help(type) for accurate signature.
help(o3d.io.read_point_cloud)
はread_point_cloud
関数の入力と出力の説明を返す.
help(o3d.io.read_point_cloud)
Help on built-in function read_point_cloud in module open3d.open3d.io: read_point_cloud(...) method of builtins.PyCapsule instance read_point_cloud(filename, format='auto', remove_nan_points=True, remove_infinite_points=True, print_progress=False) Function to read PointCloud from file Args: filename (str): Path to file. format (str, optional, default='auto'): The format of the input file. When not specified or set as ``auto``, the format is inferred from file extension name. remove_nan_points (bool, optional, default=True): If true, all points that include a NaN are removed from the PointCloud. remove_infinite_points (bool, optional, default=True): If true, all points that include an infinite value are removed from the PointCloud. print_progress (bool, optional, default=False): If set to true a progress bar is visualized in the console Returns: open3d.geometry.PointCloud