Created
March 13, 2022 19:09
-
-
Save HViktorTsoi/18a17a7a3cfe1cd4715d6c18823809fd to your computer and use it in GitHub Desktop.
Open3D non-blocking visualizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import open3d as o3d | |
import time | |
class NonBlockVisualizer: | |
def __init__(self, point_size=2, background_color=[0, 0, 0]): | |
self.__visualizer = o3d.visualization.Visualizer() | |
self.__visualizer.create_window() | |
opt = self.__visualizer.get_render_option() | |
opt.background_color = np.asarray(background_color) | |
opt = self.__visualizer.get_render_option() | |
opt.point_size = point_size | |
self.__pcd_vis = o3d.geometry.PointCloud() | |
self.__initialized = False | |
def update_renderer(self, pcd, wait_time=0): | |
self.__pcd_vis.points = pcd.points | |
self.__pcd_vis.colors = pcd.colors | |
if not self.__initialized: | |
self.__initialized = True | |
self.__visualizer.add_geometry(self.__pcd_vis) | |
else: | |
self.__visualizer.update_geometry(self.__pcd_vis) | |
self.__visualizer.poll_events() | |
self.__visualizer.update_renderer() | |
if wait_time > 0: | |
time.sleep(wait_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment