Open3D繪制3D坐標,繪制點雲

pan_jinquan 2021-08-15 21:12:17 阅读数:609

本文一共[544]字,预计阅读时长:1分钟~
open3d open

Open3D繪制3D坐標,繪制點雲

 

# -*-coding: utf-8 -*-
"""
@Project: PyKinect2-OpenCV
@File : open3d_test.py
@Author : panjq
@E-mail : [email protected]
@Date : 2019-10-10 09:49:27
"""
import open3d
import numpy as np
import cv2
# 繪制open3d坐標系
axis_pcd = open3d.create_mesh_coordinate_frame(size=0.5, origin=[0, 0, 0])
# 在3D坐標上繪制點:坐標點[x,y,z]對應R,G,B顏色
points = np.array([[0.1, 0.1, 0.1], [1, 0, 0], [0, 1, 0], [0, 0, 1]])
colors = [[1, 1, 1], [1, 0, 0], [0, 1, 0], [0, 0, 1]]
test_pcd = open3d.geometry.PointCloud() # 定義點雲
# 方法1(非阻塞顯示)
vis = open3d.Visualizer()
vis.create_window(window_name="Open3D1")
vis.get_render_option().point_size = 3
first_loop = True
# 先把點雲對象添加給Visualizer
vis.add_geometry(axis_pcd)
vis.add_geometry(test_pcd)
while True:
# 給點雲添加顯示的數據
points -= 0.001
test_pcd.points = open3d.utility.Vector3dVector(points) # 定義點雲坐標比特置
test_pcd.colors = open3d.Vector3dVector(colors) # 定義點雲的顏色
# update_renderer顯示當前的數據
vis.update_geometry()
vis.poll_events()
vis.update_renderer()
cv2.waitKey(100)
# 方法2(阻塞顯示):調用draw_geometries直接把需要顯示點雲數據
test_pcd.points = open3d.utility.Vector3dVector(points) # 定義點雲坐標比特置
test_pcd.colors = open3d.Vector3dVector(colors) # 定義點雲的顏色
open3d.visualization.draw_geometries([test_pcd] + [axis_pcd], window_name="Open3D2")

版权声明:本文为[pan_jinquan]所创,转载请带上原文链接,感谢。 https://gsmany.com/2021/08/20210815211145769x.html