Last active
March 23, 2023 03:29
-
-
Save yudai09/263654ec2df6cbfc72471e7d4ee04537 to your computer and use it in GitHub Desktop.
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 numpy as np | |
import laspy as lp | |
import open3d as o3d | |
import time | |
def main(): | |
pcd = o3d.geometry.PointCloud() | |
points, colors = load_las_file() | |
pcd.points = o3d.utility.Vector3dVector(points) | |
pcd.colors = o3d.utility.Vector3dVector(colors) | |
vis = o3d.visualization.Visualizer() | |
# ヘッドレスレンダリングによって物理スクリーンのサイズにとらわれない解像度の出力が可能になる。 | |
# オプションをつけてビルドする必要がある。 | |
# 手順は公式にかかれているとおりhttp://www.open3d.org/docs/latest/tutorial/Advanced/headless_rendering.html | |
vis.create_window(width=3000, height=3000, visible=False) | |
vis.get_render_option().point_size = 1.0 | |
vis.get_view_control().change_field_of_view(-90) # 5度以下を設定するとOrthoになる。 https://github.com/isl-org/Open3D/issues/2367 | |
# 有効にならない。↑はversion0.17.0で起きているバグ。 https://github.com/isl-org/Open3D/issues/6009 | |
# ひとまず直るまで静観しよう。 | |
vis.add_geometry(pcd) | |
vis.update_geometry(pcd) | |
vis.poll_events() | |
vis.update_renderer() | |
time.sleep(1) | |
vis.capture_screen_image('ortho.png', do_render=False) | |
def load_las_file(): | |
path = "2020_Drone_M.las" | |
point_cloud=lp.open(open(path, "rb")).read() | |
points = np.vstack((point_cloud.x, point_cloud.y, point_cloud.z)).transpose() | |
colors = np.vstack((point_cloud.red, point_cloud.green, point_cloud.blue)).transpose() | |
colors = colors / 65535 | |
return points, colors | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment