2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Open3D便利帳

Posted at

自分用
順次更新

点群データの初期化

import open3d as o3d
pcd = o3d.geometry.PointCloud()

可視化

クラスにしておくと便利

class VISUALIZE():

    pc = o3d.geometry.PointCloud()
    
    def __init__(self, pc):
        # ウィンドウの作成
        self.vis = o3d.visualization.Visualizer()
        self.vis.create_window()
        self.vis.clear_geometries()

        # 座標軸の作成と描画
        coordinate_frame = o3d.geometry.TriangleMesh.create_coordinate_frame(size=500, origin=[0, 0, 0])
        self.vis.add_geometry(coordinate_frame)

        # 点群の登録
        self.pc = pc
        self.vis.add_geometry(self.pc)

        # 点群の大きさ
        render_option = self.vis.get_render_option()
        render_option.point_size = 10.0

    def update(self, pc):
        # 点群の更新
        self.pc = pc
        self.vis.update_geometry(self.pc)

        # 描画の更新
        self.vis.poll_events()
        self.vis.update_renderer()

    def destroy(self):
        self.vis.destroy_window()
VIS = VISUALIZE(pcd)

for i in 何らかのループ
    何らかの処理
    VIS.update(pcd)

VIS.destroy()

Numpyへ変換

import numpy as np
pdc_np = np.asarray(pcd.points)

jsonにして記録

txt = '{'
for i in 何らかのループ
    何らかの処理
    formatted_pts3d = ','.join([f"[{p[0]:.1f},{p[1]:.1f},{p[2]:.1f}]" for p in pdc_np])
    txt = txt + '"pcd":['  + formatted_pts3d + '],'
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?