Python点云数据处理(六)Open3d补充:点云基本处理 - 知乎 https://zhuanlan.zhihu.com/p/353971365?utm_id=0
open3d绘制点云1–单帧点云 - 知乎 https://zhuanlan.zhihu.com/p/591249741
(168条消息) open3D 的使用,pcd可视化,3D bbox可视化,web_visualizer使用等。_CV矿工的博客-CSDN博客 https://blog.csdn.net/ZauberC/article/details/127260203
open3d.geometry.AxisAlignedBoundingBox — Open3D 0.17.0 documentation http://www.open3d.org/docs/release/python_api/open3d.geometry.AxisAlignedBoundingBox.html
Open3D 可视化(1)——简单可视化_o3d.visualization.draw_geometries_Dove_1234的博客-CSDN博客 https://blog.csdn.net/baidu_39332177/article/details/127792817
爆肝5万字❤️Open3D 点云数据处理基础(Python版) - 小智博客 http://imyhq.com/design/312.html#23__191
测试文件Area_5_office_10.npy下载
用open3D可以弹出一个窗口,支持鼠标旋转和放缩,很方便
#不显示天花板和天花板上的灯
#coding=utf-8
import open3d as o3d
import numpy as np
np.set_printoptions(suppress=True) # 取消默认科学计数法,open3d无法读取科学计数法表示
data = np.load("C:/Users/mi/Desktop/trash/Area_5_office_10.npy")# point_num, x、y、z、r、g、b、label
data = data[data[:,6]!=0] # 0 cell:去除天花板
data = data[data[:,6]!=12] # 12 :去除天花板上的灯
b = np.array([1 , 1, 1,255, 255, 255]) # 每一列要除的数
np.savetxt('scene.txt', data[:,:6]/b)
# 读取点云并可视化
pcd =o3d.io.read_point_cloud("scene.txt", format='xyzrgb') # 原npy文件中的数据正好是按x y z r g b进行排列
# print(pcd)
o3d.visualization.draw_geometries([pcd], width=1200, height=600)
import open3d as o3d
import numpy as np
from copy import deepcopy
if __name__ == '__main__':
# point_num, x、y、z、r、g、b、label
points = np.load('C:/Users/mi/Desktop/trash/Area_5_office_10.npy')
data = data[data[:,6]!=0] # 0 cell:去除天花板
data = data[data[:,6]!=12] # 12 :去除天花板上的灯
preds = points[:,-1]
print(preds.shape, points.shape)
print(set(preds))
# 随机生成13个类别的颜色
colors_0 = np.random.randint(255, size=(13, 3)) / 255.
# 获取场景的点
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points[:, :3])
# 为各个真实标签指定颜色
colors = colors_0[points[:, -1].astype(np.uint8)]
pcd.colors = o3d.utility.Vector3dVector(colors[:, :3])
# 显示现实颜色
pcd1 = deepcopy(pcd)
pcd1.translate((0, 5, 0)) # 整体进行y轴方向平移5
pcd1.colors = o3d.utility.Vector3dVector(points[:,3:6]/255)
# 点云显示
o3d.visualization.draw_geometries([pcd, pcd1], window_name="xxx语义分割结果",
point_show_normal=False,
width=800, # 窗口宽度
height=600)
文件下载
import open3d as o3d
import numpy as np
from copy import deepcopy
if __name__ == '__main__':
# pc_num, 6.
#6: xyzrgb
points = np.load('C:/Users/mi/Desktop/trash/pc.npy')
# pc_num
gt = np.load('C:/Users/mi/Desktop/trash/gt_l.npy')
# pc_num, 1
gt = gt.reshape(-1,1)
# pc_num
pre = np.load('C:/Users/mi/Desktop/trash/pre_l.npy')
# pc_num, 1
pre = pre.reshape(-1,1)
points = np.concatenate([points, gt, pre], axis=-1)
# concatenate((a, b, c), axis=0)
points = points[points[:, 6] != 0]
points = points[points[:, 6] != 12]
gt = points[:,6]
pre = points[:,7]
# 随机生成13个类别的颜色
colors_0 = np.random.randint(255, size=(13, 3)) / 255.
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points[:, :3])
# 为各个真实标签指定颜色
colors = colors_0[gt.astype(np.uint8)]
pcd.colors = o3d.utility.Vector3dVector(colors[:, :3])
# 显示现实颜色
pcd1 = deepcopy(pcd)
pcd1.translate((0, 9, 0)) # 整体进行y轴方向平移5
# 为各个预测标签指定颜色
# colors = colors_0[preds.astype(np.uint8)]
pcd1.colors = o3d.utility.Vector3dVector(points[:,3:6]/255)
# pre 颜色
pcd2 = deepcopy(pcd1)
pcd2.translate((0, 9, 0)) # 整体进行y轴方向平移5
# 为各个预测标签指定颜色
colors = colors_0[pre.astype(np.uint8)]
pcd2.colors = o3d.utility.Vector3dVector(colors[:, :3])
# 点云显示
o3d.visualization.draw_geometries([pcd, pcd1, pcd2], window_name="PointNet++语义分割结果",
point_show_normal=False,
width=800, # 窗口宽度
height=600)
每个检测的Box,可由
文件下载
import open3d as o3d
import numpy as np
from copy import deepcopy
i =9
# pc_num, xyz
points = np.load('C:/Users/mi/Desktop/trash/box/npy/gt_pc_'+str(i)+'_.npy')
# pc_num, rgb
color = np.load('C:/Users/mi/Desktop/trash/box/npy/color_'+str(i)+'_.npy')
# gt
# box_num,xyz
gt_box_center = np.load('C:/Users/mi/Desktop/trash/box/npy/gt_box_center_'+str(i)+'_.npy')
#box_num,angle
gt_box_angles = np.load('C:/Users/mi/Desktop/trash/box/npy/gt_box_angle_'+str(i)+'_.npy').reshape(-1,1)
# box_num,lwh
gt_box_size = np.load('C:/Users/mi/Desktop/trash/box/npy/gt_box_size_'+str(i)+'_.npy')
point_cloud = o3d.geometry.PointCloud()
point_cloud.points = o3d.utility.Vector3dVector(points[:, :3])
point_cloud.colors = o3d.utility.Vector3dVector(color/255)
vis = o3d.visualization.Visualizer()
vis.create_window()
vis.add_geometry(point_cloud)
gt_boxes = np.concatenate([gt_box_center, gt_box_size, gt_box_angles], axis=-1)
for i, box in enumerate(gt_boxes):
b = o3d.geometry.OrientedBoundingBox()
b.center = box[:3]
b.extent = box[3:6]
# with heading
R = o3d.geometry.OrientedBoundingBox.get_rotation_matrix_from_xyz((0, 0, box[6]))
b.rotate(R, b.center)
b.color = (1,1,0)
vis.add_geometry(b)
# vis.get_render_option().background_color = np.asarray([0, 0, 0]) # 设置一些渲染属性
vis.run()
vis.destroy_window()
一些大型场景的图片,放大后可以比较gt和pre
https://www.yingsoo.com/news/devops/37918.html