Python interface

For the C++ interface see C++ interface.

Install open3d Python package

For installing Open3D Python package, see Installing from PyPI or Conda.

Install open3d from source

For installing from source, see Compiling from source.

Import open3d module

This tutorial shows how to import open3d module and print out help information. For trouble shooting, see 2. Setup Python binding environments.

 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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()

This scripts has two functions: example_help_function and example_import_all that show very basic usage of Open3D Python module.

Note

Depending on environment, the name of Python library may not be open3d.so. Regardless of the file name, import open3d should work.

10
11
12
def example_import_function():
    pcd = o3d.io.read_point_cloud("../../TestData/ICP/cloud_bin_0.pcd")
    print(pcd)

This imports read_point_cloud function from open3d module. It reads a point cloud file and returns an instance of PointCloud class. print(pcd) prints brief information of the point cloud:

PointCloud with 198835 points.

Using built-in help function

It is recommended to use Python built-in help function to get definitions and instructions of Open3D functions and classes. For example,

15
16
17
18
def example_help_function():
    help(o3d)
    help(o3d.geometry.PointCloud)
    help(o3d.io.read_point_cloud)

Browse open3d

help(open3d) prints documents of open3d module.

Help on module open3d:

NAME
    open3d - Python binding of Open3D

FILE
    /Users/myaccount/Open3D/build/lib/open3d.so

CLASSES
    __builtin__.object
        CorrespondenceChecker
            CorrespondenceCheckerBasedOnDistance
            CorrespondenceCheckerBasedOnEdgeLength
            CorrespondenceCheckerBasedOnNormal
        DoubleVector
        Feature
        Geometry
            Geometry2D
                Image
            Geometry3D
                PointCloud
                TriangleMesh
:

Description of a class in open3d

help(open3d.PointCloud) provides description of PointCloud class.

Help on class PointCloud in module open3d:

class PointCloud(Geometry3D)
 |  Method resolution order:
 |      PointCloud
 |      Geometry3D
 |      Geometry
 |      __builtin__.object
 |
 |  Methods defined here:
 |
 |  __add__(...)
 |      __add__(self: open3d.PointCloud, arg0: open3d.PointCloud) -> open3d.PointCloud
 |
:

Description of a function in open3d

help(open3d.read_point_cloud) provides description of input argument and return type of read_point_cloud function.

Help on built-in function read_point_cloud in module open3d:

read_point_cloud(...)
    read_point_cloud(filename: unicode) -> open3d.PointCloud

    Function to read PointCloud from file