📖
Wiki
Back to my personal website
  • Home
  • Equipment and Devices
    • 3D Printer
    • Laser Cutter
    • Motion Capture System
    • Sensors
      • RGB-D Cameras
      • Velodyne LiDAR
      • Zed Camera
      • RealSense D435i
      • IMU
    • eGPU
    • Nvidia AGX Xavier
    • CPU Benchmark
    • Installation Checklist
  • Development
    • Linux
      • Shell
      • GDB
      • Git
      • Tmux
      • Network
      • Tricks
      • Debug FAQ
    • CMake
      • Catkin Tools
      • CMakeLists
      • CMake Variables
      • CMake Commands
      • CMake: find_package()
    • ROS
      • Gazebo
      • wstool
      • roslaunch
      • rosbag
      • multi-threaded spinner
    • ROS2
      • Convert ROS1 bag to ROS2 bag
    • C++
      • C++ 11
      • C++ Examples
      • C++ Debug
      • Factory Method
      • Timing
    • Google Tools
      • GLog
      • GFlags
      • GTest
      • Style Guide
      • Clang Format
    • PCL
      • Point Type
      • Methods
      • Architecture
      • Code Explained
    • Open3D
      • Python API
      • Registration
      • Visualization
      • Tools
    • OpenCV
      • Documentation
      • Modules
    • Other Libraries
      • Eigen
      • Ceres
      • g2o
      • GTSAM
    • Website
  • Algorithm
    • SLAM
      • K-D Tree
      • Octree
      • Bag of Words
      • Distance Measures
      • Coordinate Systems
      • LOAM
      • Iterative Closest Point
      • Generalized ICP
      • Mahalanobis Distance
    • Computer Science
      • Computational Model
      • Sorting
      • Analysis
      • Complexity Classes (P, NP)
      • Divide and Conquer
      • Greedy Algorithm
      • Dynamic Programming
      • Tree
      • Graph
    • Computer Vision
      • Camera Models
      • Distortion
      • Motion Models
      • Shutter
      • Image Sensors
      • Epipolar Geometry
      • Multiple-View Geometry
    • Datasets
      • RGB-D Datasets
      • Point Cloud Datasets
      • LiDAR SLAM Datasets
  • Math
    • Optimization
      • Convex Optimization
      • Descent Methods
    • Probability
      • Moment
      • Covariance Matrix
      • Stochastic Process
    • Topology
      • References
      • Concepts
      • Topological Spaces
      • Representation of Rotations
      • Representation of 3-sphere
    • Algebra
      • Linear Algebra
      • Matrix Factorization
      • Condition Number
      • Matrix Lie Group
    • Differential Geometry
      • Manifold
      • Submanifold
      • Quotient Manifolds
      • Tangent Space
  • Quadrotor
    • PX4 Development
    • Companion Computer
    • Drone Hardware
    • Propeller Lock
    • Debug
  • Favorites
    • Bookmarks
Powered by GitBook
On this page
  • I/O
  • Geometry
  • Visualization

Was this helpful?

  1. Development
  2. Open3D

Python API

I/O

# read and write
cloud1 = o3d.io.read_point_cloud("cloud1.pcd")
cloud2 = o3d.io.read_point_cloud("cloud2.ply")
o3d.io.write_point_cloud("cloud3.pcd", cloud3)

Geometry

# use np.asarray() to access data
cloud_ndarray = np.asarray(cloud.points)

# use o3d.utility.Vector3dVector to convert to o3d format
cloud.points = o3d.utility.Vector3dVector(cloud_ndarray)

# can also change data using np.asarray
np.asarray(cloud.colors)[idx[1:], :] = [0, 1, 0] # color nbr points to green

# paint color
cloud.paint_uniform_color([1.0, 0.0, 0.0])

# K-D Tree and NN search
cloud_tree = o3d.geometry.KDTreeFlann(cloud)
[k, idx, _] = cloud_tree.search_knn_vector_3d(cloud.points[1500], 200)
[k, idx, dist] = cloud_tree.search_radius_vector_3d(query_point, radius)

Visualization

# basic viewers at high level
o3d.visualization.draw_geometries([pcd])
o3d.visualization.draw_geometries_with_editing([pcd])

# custom visualization
def custom_draw_geometry(pcd):
    # The following code achieves the same effect as:
    # o3d.visualization.draw_geometries([pcd])
    vis = o3d.visualization.Visualizer()
    vis.create_window()
    vis.add_geometry(pcd)
    vis.run()
    vis.destroy_window()

# non-blocking visualization
vis = o3d.visualization.Visualizer()
vis.create_window()
for i in range(icp_iteration):
    # do ICP single iteration
    # transform geometry using ICP
    vis.update_geometry(geometry)
    vis.poll_events()
    vis.update_renderer()
PreviousOpen3DNextRegistration

Last updated 3 years ago

Was this helpful?