点云可视化 open3D
禁止转载
好博客汇总
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可以弹出一个窗口,支持鼠标旋转和放缩,很方便
方案1:npy文件包含位置和颜色
#不显示天花板和天花板上的灯
#coding=utf-8
import open3d as o3d
import numpy as npnp.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、labeldata = 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
import timeif __name__ == '__main__':i = 53dis = 0points = np.load('F:/temp_save/npy/pc_' + str(i) + '_.npy')gt = np.load('F:/temp_save/npy/gt_l_' + str(i) + '_.npy').reshape(-1, 1)pre_point_1 = np.load('F:/temp_save/npy/point_LGMask_pre_l_' + str(i) + '_.npy').reshape(-1, 1)pre_point_2 = np.load('F:/temp_save/npy/point_2_pre_l_' + str(i) + '_.npy').reshape(-1, 1)points = np.concatenate([points, gt, pre_point_1, pre_point_2], axis=-1)# concatenate((a, b, c), axis=0)points = points[points[:, 6] != 0] # 不要天花板类points = points[points[:, 2] < 2.5] # 尽量排掉 日光灯gt = points[:, 6]pre_point_1 = points[:, 7]pre_point_2 = points[:, 8]# 随机生成13个类别的颜色# colors_0 = np.random.randint(255, size=(13, 3)) / 255.colors_0 = [[0, 255, 0],[19, 0, 255],[0, 255, 255],[255, 255, 0],[255, 0, 255],[100, 100, 255],[200, 200, 100],[170, 121, 200],[255, 0, 0],[200, 100, 100],[10, 200, 100],[200, 200, 200],[50, 50, 50]]colors_0 = np.array(colors_0) / 255pcd = o3d.geometry.PointCloud()pcd.points = o3d.utility.Vector3dVector(points[:, :3])# 显示现实颜色pcd.colors = o3d.utility.Vector3dVector(points[:, 3:6] / 255)# gtpcd1 = deepcopy(pcd)pcd1.translate((0, dis, 0)) # 整体进行y轴方向平移5# 为各个预测标签指定颜色colors = colors_0[gt.astype(np.uint8)]pcd1.colors = o3d.utility.Vector3dVector(colors[:, :3])# pre point_1颜色pcd2 = deepcopy(pcd1)pcd2.translate((0, dis, 0)) # 整体进行y轴方向平移5# 为各个预测标签指定颜色colors = colors_0[pre_point_1.astype(np.uint8)]pcd2.colors = o3d.utility.Vector3dVector(colors[:, :3])# pre point_2颜色pcd3 = deepcopy(pcd2)pcd3.translate((0, dis, 0)) # 整体进行y轴方向平移5# 为各个预测标签指定颜色colors = colors_0[pre_point_2.astype(np.uint8)]pcd3.colors = o3d.utility.Vector3dVector(colors[:, :3])# 点云显示# o3d.visualization.draw_geometries([pcd, pcd1, pcd2, pcd3], window_name="PointNet++语义分割结果",# point_show_normal=False,# width=800, # 窗口宽度# height=600)vis = o3d.visualization.Visualizer()vis.create_window()opt = vis.get_render_option()opt.point_size =5opt.background_color = np.asarray([1, 1, 1])# vis.add_geometry(pcd)# vis.add_geometry(pcd1)# vis.add_geometry(pcd2)vis.add_geometry(pcd3)vis.update_geometry(pcd)vis.run()vis.destroy_window()
参考的博客
方案2:npy 文件 位置跟颜色分离
- 点跟颜色分离处理
- 点由原始的输入提供
- 颜色可自定义为,现实颜色、gt label颜色、pre label 颜色
import open3d as o3d
import numpy as np
from copy import deepcopyif __name__ == '__main__':# point_num, x、y、z、r、g、b、labelpoints = 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轴方向平移5pcd1.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)
参考的博客
方案3:同时显示现实颜色、gt、pre label
文件下载
import open3d as o3d
import numpy as np
from copy import deepcopyif __name__ == '__main__':# pc_num, 6. #6: xyzrgbpoints = np.load('C:/Users/mi/Desktop/trash/pc.npy')# pc_numgt = np.load('C:/Users/mi/Desktop/trash/gt_l.npy')# pc_num, 1gt = gt.reshape(-1,1)# pc_numpre = np.load('C:/Users/mi/Desktop/trash/pre_l.npy')# pc_num, 1pre = 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)
用open3D 可视化点云的方向统一
- 有时候需要将real、gt 和 pred 的图都展示,但视角要统一。
- 先在一个图上(比如 gt )确定展示的视角(鼠标控制)
- ctr+c
- 在新的图(比如real),打开后只需 ctr+v,即可旋转到跟gt一样的视角
参考的博客
区域放大
放大图片区域,在比较语义分割实验效果上有用
import cv2 as cv
import sys
import numpy as npdef big_part_in_img_2(img, need_big_part_pos, big_show_pos, need_big_part_half_l, line_type=1):time = 4 # 放大倍数line_big = 5 # 连线的宽度line_color = (0, 0, 0) # 连线的颜色rectangle_line_big = 7 # 矩形框的宽度rectangle_color =(0,0,255) # 矩形框的颜色big_half_l = need_big_part_half_l * time# 需要被放大的区域part = img[(need_big_part_pos[0] - need_big_part_half_l):(need_big_part_pos[0] + need_big_part_half_l),(need_big_part_pos[1] - need_big_part_half_l):(need_big_part_pos[1] + need_big_part_half_l)]# 双线性插值法mask = cv.resize(part, (big_half_l * 2, big_half_l * 2), fx=0, fy=0, interpolation=cv.INTER_LINEAR)if img is None is None:print('Failed to read picture')sys.exit()# 放大后局部图的位置img[210:410,670:870# aa = img[(big_show_pos[0] - big_half_l):(big_show_pos[0] + big_half_l),# (big_show_pos[0] - big_half_l):(big_show_pos[0] + big_half_l)]img[(big_show_pos[0] - big_half_l):(big_show_pos[0] + big_half_l),(big_show_pos[1] - big_half_l):(big_show_pos[1] + big_half_l)] = mask# 画框并连线cv.rectangle(img, ((need_big_part_pos[1] - need_big_part_half_l), (need_big_part_pos[0] - need_big_part_half_l)),((need_big_part_pos[1] + need_big_part_half_l), (need_big_part_pos[0] + need_big_part_half_l)),rectangle_color, rectangle_line_big)cv.rectangle(img, ((big_show_pos[1] - big_half_l), (big_show_pos[0] - big_half_l)),((big_show_pos[1] + big_half_l), (big_show_pos[0] + big_half_l)), rectangle_color, rectangle_line_big)if line_type == 1:img = cv.line(img, (big_show_pos[1] - big_half_l, big_show_pos[0] + big_half_l),(need_big_part_pos[1] - need_big_part_half_l, need_big_part_pos[0] - need_big_part_half_l),line_color,line_big, cv.LINE_AA)img = cv.line(img, (big_show_pos[1] + big_half_l, big_show_pos[0] + big_half_l),(need_big_part_pos[1] + need_big_part_half_l, need_big_part_pos[0] - need_big_part_half_l),line_color,line_big, cv.LINE_AA)elif line_type == 2:img = cv.line(img, (big_show_pos[1] - big_half_l, big_show_pos[0] - big_half_l),(need_big_part_pos[1] + need_big_part_half_l, need_big_part_pos[0] - need_big_part_half_l),line_color,line_big, cv.LINE_AA)img = cv.line(img, (big_show_pos[1] - big_half_l, big_show_pos[0] + big_half_l),(need_big_part_pos[1] + need_big_part_half_l, need_big_part_pos[0] + need_big_part_half_l),line_color,line_big, cv.LINE_AA)elif line_type == 3:img = cv.line(img, (big_show_pos[1] - big_half_l, big_show_pos[0] - big_half_l),(need_big_part_pos[1] - need_big_part_half_l, need_big_part_pos[0] + need_big_part_half_l),line_color,line_big, cv.LINE_AA)img = cv.line(img, (big_show_pos[1] + big_half_l, big_show_pos[0] - big_half_l),(need_big_part_pos[1] + need_big_part_half_l, need_big_part_pos[0] + need_big_part_half_l),line_color,line_big, cv.LINE_AA)elif line_type == 4:img = cv.line(img, (big_show_pos[1] + big_half_l, big_show_pos[0] - big_half_l),(need_big_part_pos[1] - need_big_part_half_l, need_big_part_pos[0] - need_big_part_half_l),line_color,line_big, cv.LINE_AA)img = cv.line(img, (big_show_pos[1] + big_half_l, big_show_pos[0] + big_half_l),(need_big_part_pos[1] - need_big_part_half_l, need_big_part_pos[0] + need_big_part_half_l),line_color,line_big, cv.LINE_AA)return imgif __name__ == '__main__':name = 'real'img = cv.imread('C:/Users/mi/Desktop/trash/vis/'+name+'.png')img = img[20:-25, 20:-25,:] # 去除图片边缘不要的信息# cv.imwrite('test.jpg', img)# 将图换到更大的背景下arr = np.ones((1500, 2500, 3))*255arr[0+300:img.shape[0]+300, 0+300:img.shape[1]+300,:] = imgcv.imwrite('test_2.jpg', arr)img = cv.imread('test_2.jpg')# exit()# need_big_part_pos = [200, 1000], 200表示在图的上下滑动位置; 1000表示在图的左右滑动位置# # need_big_part_pos 是需要放大的区域中心位置# big_show_pos是放大后的区域显示的位置## line_type = 3.其中:# 1:big_show_pos 在need_big_part_pos上边# 2: big_show_pos 在need_big_part_pos 右边# 3: big_show_pos 在need_big_part_pos 下边# 4: big_show_pos 在need_big_part_pos 左边img = big_part_in_img_2(img,need_big_part_half_l=60, need_big_part_pos = [480, 1100],big_show_pos = [350, 1750], line_type=2)img = big_part_in_img_2(img,need_big_part_half_l=60, need_big_part_pos = [550, 930],big_show_pos = [1100, 600], line_type=3)# 展示结果# cv.imwrite(name+'_ed.png', img)# exit()h, w = img.shape[:2]if w > 800:img = cv.resize(img, (800, int(h * 800 / w)))cv.imshow('img', img)cv.waitKey(0)cv.destroyAllWindows()
参考博客
目标检测可视化
每个检测的Box,可由
- box_center: box中心的位置,xyz
- box_size:每个Box 长宽高的一半, lwh
- Box_angle:默认box 绕z轴旋转,r
文件下载
import open3d as o3d
import numpy as np
from copy import deepcopyi =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 headingR = 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()
点云可视化 open3D相关推荐
- python点云可视化_3D可视化神器之Open3D
很多时候在python里面你要找一个3D点云可视化的库真的是难啊.你的选择可能是:pcl mayavi matplolib 但是以上都不好用,pcl甚至没有靠谱的python wrapper,唯一一个 ...
- python open3d点云可视化(本节会根据实际所用持续更新)
本文为博主原创文章,未经博主允许不得转载. 本文为专栏<python三维点云从基础到深度学习>系列文章,地址为"https://blog.csdn.net/suiyingy/ar ...
- 点云 3D 可视化 - Open3D 库
点云 3D 可视化 - Open3D 库 1. 文章信息 2. Open3D 库简介 2. 3D 可视化使用 2.1 单帧点云 2.2 多帧点云 1. 文章信息 (1)标题:Open3D: A Mod ...
- win下使用QT添加VTK插件实现点云可视化GUI
摘要 大家在做点云的时候经常会用到QT,但是我们需要使用QT做点云的可视化的时候又需要VTK,虽然我们在windows下安装PCL的时候就已经安装了VTK,由于跟着PCL安装的VTK是没有和QT联合 ...
- 重磅直播|大规模点云可视化技术
点击上方"3D视觉工坊",选择"星标" 干货第一时间送达 大家好,本公众号现已开启线上视频公开课,主讲人通过B站直播间,对3D视觉领域相关知识点进行讲解,并在微 ...
- 手把手:R语言文本挖掘和词云可视化实践
互联网时代,大量的新闻信息.网络交互.舆情信息以文本形式存储在数据库中,如何利用数据分析和文本挖掘的算法,将海量文本的价值挖掘出来,成为我们团队近期的一个研究方向,本案例就是我们的一个初步尝试.飞信群 ...
- creator qt 设置换行方式_win下使用QT添加VTK插件实现点云可视化GUI
大家在做点云的时候经常会用到QT,但是我们需要使用QT做点云的可视化的时候又需要VTK,虽然我们在windows下安装PCL的时候就已经安装了VTK,由于跟着PCL安装的VTK是没有和QT联合编译的, ...
- 将QVTKWidget嵌入到QT窗体,实现点云可视化的基本操作
将QVTKWidget嵌入到QT窗体,实现点云可视化的基本操作 网络上的朋友都在讲,做点云数据处理的童鞋都希望做一个属于自己的点云可视化的界面,不论是情怀还是业务需要,我都做了一个1.0.1版本的可视 ...
- 下c语言实现wc_用 Python 实现词云可视化
词云是一种非常漂亮的可视化展示方式,正所谓一图胜过千言万语,词云在之前的项目中我也有过很多的使用,可能对于我来说,一种很好的自我介绍方式就是词云吧,就像下面这样的: 个人觉还是会比枯燥的文字语言描述性 ...
最新文章
- Windows 远程桌面管理
- 【原创】2009个性签名和流行语搜集
- leetcode 621. 任务调度器(贪心算法)
- Linux 系统如何查看硬盘UUID与修改
- 【MySQL】MySQL USE 库的时候报错 Reading table information for completion of table and column names
- Linux升级php
- SQL Server数据库log shipping 灾备(Part2 )
- 觉得做人累了就看看这些!不是社会错了,是你错了!写的超好!
- 在Linux环境下安装MYSQL
- swap使用率达到100%的解决办法
- Extjs学习(3):事件和动作
- VisualStudio2022如何改为中文语言(vs2022汉化)
- opencv-python中文文档
- 《英雄联盟》捞月狗数据初探
- 令人震惊!JSP已经淘汰,却才搞明白JSP和Servlet之间不可告人的关系!
- Halcon教程六:为什么要二值化
- 分子动力学模拟计算新冠病毒S蛋白和抗体结合自由能
- 自制冰箱,冰柜蒸发器和毛细管的速算
- python——基础应用:顺丰快递分拣小程序的实现
- MyBatis中设置事务自动提交