Open 3D 사용 방법: 읽기 및 표시, 점 및 법선 가져오기
15197 단어 PointCloudPythonOpen3D
설치하다.
cmake로 구축.
사용 방법 탐색
ply를 불러와서 읽은 점 그룹과 법선 데이터에 접근합니다.
Stanford bunny 의 play 파일을 사용합니다.
open3d.pyimport sys
sys.path.append("../..") # ビルドしたディレクトリ Open3D/build/lib/ へのパス
import numpy as np
import py3d
print("read ply points#############################")
pcd1 = py3d.read_point_cloud("bun000.ply") # メッシュなしply
print("pcd1:", pcd1)
print("has points?", pcd1.has_points())
point_array = np.asarray(pcd1.points)
print(point_array.shape, "points:\n", point_array)
print("has color?", pcd1.has_colors())
print("colors:", np.asarray(pcd1.colors))
print("has normals?", pcd1.has_normals())
py3d.draw_geometries([pcd1], window_name="pcd1 without normals", width=640, height=480)
print("estimate normal#############################")
py3d.estimate_normals(pcd1, search_param = py3d.KDTreeSearchParamHybrid(radius=0.1, max_nn=30))
print("has normals?", pcd1.has_normals())
normal_array = np.asarray(pcd1.normals)
print(normal_array.shape, "normals:\n", normal_array)
py3d.draw_geometries([pcd1], "pcd1 with normals", 640, 480)
print("read ply mesh#############################")
pcd2 = py3d.read_triangle_mesh("bun000mesh.ply") # メッシュありply
print("has triangle normals?", pcd2.has_triangle_normals())
print("triangle normals:\n", np.asarray(pcd2.triangle_normals))
print("has triangles?", pcd2.has_triangles())
print("triangles:", np.asarray(pcd2.triangles))
print("has vertices?", pcd2.has_vertices())
print("has vertex colors?", pcd2.has_vertex_colors())
print("vertex colors:", np.asarray(pcd2.vertex_colors))
print("has vertex normals?", pcd2.has_vertex_normals())
print("vertex normals:\n", np.asarray(pcd2.vertex_normals))
py3d.draw_geometries([pcd2], "pcd2 with mesh but no normals", 640, 480)
print("estimate normal#############################")
pcd2.compute_vertex_normals()
print("has triangle normals?", pcd2.has_triangle_normals())
print("triangle normals:\n", np.asarray(pcd2.triangle_normals))
print("has triangles?", pcd2.has_triangles())
print("triangles:", np.asarray(pcd2.triangles))
print("has vertices?", pcd2.has_vertices())
print("has vertex colors?", pcd2.has_vertex_colors())
print("vertex colors:", np.asarray(pcd2.vertex_colors))
print("has vertex normals?", pcd2.has_vertex_normals())
print("vertex normals:\n", np.asarray(pcd2.vertex_normals))
py3d.draw_geometries([pcd2], "pcd2 with mesh and normals", 640, 480)
결실
첫 번째 점의 읽기와 표시.
결실read ply points#############################
pcd1: PointCloud with 40256 points.
has points? True
(40256, 3) points:
[[-0.06325 0.0359793 0.0420873]
[-0.06275 0.0360343 0.0425949]
[-0.0645 0.0365101 0.0404362]
...
[-0.01575 0.187201 -0.0220209]
[-0.01525 0.187218 -0.0237782]
[-0.018 0.18794 -0.0197253]]
has color? False
colors: []
has normals? False
수첩에 따르다
법선을 추산하면 그늘이 진다.estimate normal#############################
has normals? True
(40256, 3) normals:
[[ 0.77476967 0.08028207 -0.62712579]
[ 0.7390345 0.08114476 -0.66876269]
[ 0.84369634 -0.03701673 -0.53554294]
...
[ 0.85078342 0.27561442 0.44744192]
[ 0.87997424 0.27744062 0.38558013]
[ 0.76228806 0.32116905 0.56193181]]
그리드를 읽은 후 vertex normal이 있어도
triangle normal이 없으면 렌더링이 평평해집니다.read ply mesh#############################
has triangle normals? False
triangle normals:
[]
has triangles? True
triangles: [[ 0 4 3]
[ 5 4 0]
[ 0 1 5]
...
[40254 40241 40242]
[40248 40249 40255]
[40255 40249 40250]]
has vertices? True
has vertex colors? False
vertex colors: []
has vertex normals? True
vertex normals:
[[-1.69331 -1.25787 1.37105 ]
[-1.30787 -1.20169 1.51385 ]
[-1.53457 -0.343746 0.839465]
...
[ 2.9521 0.500314 0.993934]
[ 1.33488 0.502489 0.407219]
[ 0.767662 0.817897 0.538318]]
법선 디스플레이를 계산합니다.estimate normal#############################
has triangle normals? True
triangle normals:
[[-0.76876577 -0.47361776 0.42975041]
[-0.58323136 -0.51290694 0.62989496]
[-0.58308966 -0.51300634 0.62994519]
...
[ 0.90297077 0.34193215 0.26024256]
[ 0.65027956 0.64132158 0.40723841]
[ 0.59599493 0.66653699 0.4477929 ]]
has triangles? True
triangles: [[ 0 4 3]
[ 5 4 0]
[ 0 1 5]
...
[40254 40241 40242]
[40248 40249 40255]
[40255 40249 40250]]
has vertices? True
has vertex colors? False
vertex colors: []
has vertex normals? True
vertex normals:
[[-0.67306678 -0.49998554 0.54497299]
[-0.56041895 -0.5149211 0.64868087]
[-0.86084632 -0.19283085 0.47091387]
...
[ 0.9357322 0.15858547 0.31504905]
[ 0.89992944 0.33876054 0.27453288]
[ 0.61698985 0.657365 0.43266012]]
Reference
이 문제에 관하여(Open 3D 사용 방법: 읽기 및 표시, 점 및 법선 가져오기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/tttamaki/items/2be476cc15fa39601243
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
ply를 불러와서 읽은 점 그룹과 법선 데이터에 접근합니다.
Stanford bunny 의 play 파일을 사용합니다.
open3d.py
import sys
sys.path.append("../..") # ビルドしたディレクトリ Open3D/build/lib/ へのパス
import numpy as np
import py3d
print("read ply points#############################")
pcd1 = py3d.read_point_cloud("bun000.ply") # メッシュなしply
print("pcd1:", pcd1)
print("has points?", pcd1.has_points())
point_array = np.asarray(pcd1.points)
print(point_array.shape, "points:\n", point_array)
print("has color?", pcd1.has_colors())
print("colors:", np.asarray(pcd1.colors))
print("has normals?", pcd1.has_normals())
py3d.draw_geometries([pcd1], window_name="pcd1 without normals", width=640, height=480)
print("estimate normal#############################")
py3d.estimate_normals(pcd1, search_param = py3d.KDTreeSearchParamHybrid(radius=0.1, max_nn=30))
print("has normals?", pcd1.has_normals())
normal_array = np.asarray(pcd1.normals)
print(normal_array.shape, "normals:\n", normal_array)
py3d.draw_geometries([pcd1], "pcd1 with normals", 640, 480)
print("read ply mesh#############################")
pcd2 = py3d.read_triangle_mesh("bun000mesh.ply") # メッシュありply
print("has triangle normals?", pcd2.has_triangle_normals())
print("triangle normals:\n", np.asarray(pcd2.triangle_normals))
print("has triangles?", pcd2.has_triangles())
print("triangles:", np.asarray(pcd2.triangles))
print("has vertices?", pcd2.has_vertices())
print("has vertex colors?", pcd2.has_vertex_colors())
print("vertex colors:", np.asarray(pcd2.vertex_colors))
print("has vertex normals?", pcd2.has_vertex_normals())
print("vertex normals:\n", np.asarray(pcd2.vertex_normals))
py3d.draw_geometries([pcd2], "pcd2 with mesh but no normals", 640, 480)
print("estimate normal#############################")
pcd2.compute_vertex_normals()
print("has triangle normals?", pcd2.has_triangle_normals())
print("triangle normals:\n", np.asarray(pcd2.triangle_normals))
print("has triangles?", pcd2.has_triangles())
print("triangles:", np.asarray(pcd2.triangles))
print("has vertices?", pcd2.has_vertices())
print("has vertex colors?", pcd2.has_vertex_colors())
print("vertex colors:", np.asarray(pcd2.vertex_colors))
print("has vertex normals?", pcd2.has_vertex_normals())
print("vertex normals:\n", np.asarray(pcd2.vertex_normals))
py3d.draw_geometries([pcd2], "pcd2 with mesh and normals", 640, 480)
결실
첫 번째 점의 읽기와 표시.
결실
read ply points#############################
pcd1: PointCloud with 40256 points.
has points? True
(40256, 3) points:
[[-0.06325 0.0359793 0.0420873]
[-0.06275 0.0360343 0.0425949]
[-0.0645 0.0365101 0.0404362]
...
[-0.01575 0.187201 -0.0220209]
[-0.01525 0.187218 -0.0237782]
[-0.018 0.18794 -0.0197253]]
has color? False
colors: []
has normals? False
수첩에 따르다 법선을 추산하면 그늘이 진다.
estimate normal#############################
has normals? True
(40256, 3) normals:
[[ 0.77476967 0.08028207 -0.62712579]
[ 0.7390345 0.08114476 -0.66876269]
[ 0.84369634 -0.03701673 -0.53554294]
...
[ 0.85078342 0.27561442 0.44744192]
[ 0.87997424 0.27744062 0.38558013]
[ 0.76228806 0.32116905 0.56193181]]
![](https://s1.md5.ltd/image/33ab932506861927a4fd078006b26daf.png)
그리드를 읽은 후 vertex normal이 있어도
triangle normal이 없으면 렌더링이 평평해집니다.
read ply mesh#############################
has triangle normals? False
triangle normals:
[]
has triangles? True
triangles: [[ 0 4 3]
[ 5 4 0]
[ 0 1 5]
...
[40254 40241 40242]
[40248 40249 40255]
[40255 40249 40250]]
has vertices? True
has vertex colors? False
vertex colors: []
has vertex normals? True
vertex normals:
[[-1.69331 -1.25787 1.37105 ]
[-1.30787 -1.20169 1.51385 ]
[-1.53457 -0.343746 0.839465]
...
[ 2.9521 0.500314 0.993934]
[ 1.33488 0.502489 0.407219]
[ 0.767662 0.817897 0.538318]]
![](https://s1.md5.ltd/image/59c71ee23f085b635db02f1794fd57e9.png)
법선 디스플레이를 계산합니다.
estimate normal#############################
has triangle normals? True
triangle normals:
[[-0.76876577 -0.47361776 0.42975041]
[-0.58323136 -0.51290694 0.62989496]
[-0.58308966 -0.51300634 0.62994519]
...
[ 0.90297077 0.34193215 0.26024256]
[ 0.65027956 0.64132158 0.40723841]
[ 0.59599493 0.66653699 0.4477929 ]]
has triangles? True
triangles: [[ 0 4 3]
[ 5 4 0]
[ 0 1 5]
...
[40254 40241 40242]
[40248 40249 40255]
[40255 40249 40250]]
has vertices? True
has vertex colors? False
vertex colors: []
has vertex normals? True
vertex normals:
[[-0.67306678 -0.49998554 0.54497299]
[-0.56041895 -0.5149211 0.64868087]
[-0.86084632 -0.19283085 0.47091387]
...
[ 0.9357322 0.15858547 0.31504905]
[ 0.89992944 0.33876054 0.27453288]
[ 0.61698985 0.657365 0.43266012]]
![](https://s1.md5.ltd/image/6f18a7cd9536bf05c2a639da0d3aab8b.png)
Reference
이 문제에 관하여(Open 3D 사용 방법: 읽기 및 표시, 점 및 법선 가져오기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/tttamaki/items/2be476cc15fa39601243텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)