当前位置:网站首页>tkinter窗口选择pcd文件并显示点云(open3d)
tkinter窗口选择pcd文件并显示点云(open3d)
2022-07-07 01:36:00 【程序员进化不脱发!】
# !/user/bin/env Python3
# -*- coding:utf-8 -*-
import open3d as o3d
import numpy as np
import os
import tkinter as tk
from tkinter import filedialog, dialog
import open3d as o3d
import numpy as np
file_path = ''
file_text = ''
vis = None
def init_window():
# ------------------------初始化显示窗口-------------------------
vis = o3d.visualization.Visualizer()
vis.create_window(window_name='pcd', width=800, height=600)
# ------------------------可视化参数设置-------------------------
opt = vis.get_render_option()
opt.background_color = np.asarray([0, 0, 0]) # 设置背景色
opt.point_size = 2 # 设置点云大小
opt.show_coordinate_frame = True # 设置是否显示坐标系
def updata_pcd(vis):
pcd = o3d.io.read_point_cloud(pcd_path)
vis.update_geometry(pcd) # 更新窗口中显示的内容
vis.add_geometry(pcd) # 添加点云到可视化窗口
vis.poll_events()
vis.update_renderer() # 更新显示窗口
vis.clear_geometries() # 清空显示内容
def choose_pcd():
''' 打开文件 :return:local_ '''
global file_path
global file_text
file_path = filedialog.askopenfilename(title=u'选择文件', initialdir=(os.path.expanduser('H:/')))
print('打开文件:', file_path)
if file_path is not None:
file_text = file_path
text1.insert('insert', file_text)
def open_point():
global file_text
print("加载pcd文件路径:" + file_text)
pcd = o3d.io.read_point_cloud(file_text)
print(pcd) # 输出点云点的个数
print(np.asarray(pcd.points)) # 输出点的三维坐标
print('给所有的点上一个统一的颜色,颜色是在RGB空间得[0,1]范围内得值')
pcd.paint_uniform_color([0, 1, 0])
o3d.io.write_point_cloud("copy_of_fragment.pcd", pcd)
o3d.visualization.draw_geometries([pcd])
if __name__ == '__main__':
window = tk.Tk()
window.title('窗口标题') # 标题
window.geometry('500x300') # 窗口尺寸
text1 = tk.Text(window, width=50, height=10, bg='orange', font=('Arial', 12))
text1.pack()
vis1 = init_window()
bt1 = tk.Button(window, text='选择pcd文件', width=15, height=2, command=choose_pcd)
bt1.pack()
bt2 = tk.Button(window, text='打开点云', width=15, height=2, command=open_point)
bt2.pack()
window.mainloop() # 显示
边栏推荐
- JMeter's own functions are not enough? Why don't you develop one yourself
- The boss always asks me about my progress. Don't you trust me? (what do you think)
- Rk3399 platform development series explanation (WiFi) 5.52. Introduction to WiFi framework composition
- Classic questions about data storage
- go-microservice-simple(2) go-Probuffer
- Flask1.1.4 Werkzeug1.0.1 源码分析:启动流程
- 高并发大流量秒杀方案思路
- Financial risk control practice - decision tree rule mining template
- [solved] record an error in easyexcel [when reading the XLS file, no error will be reported when reading the whole table, and an error will be reported when reading the specified sheet name]
- Subghz, lorawan, Nb IOT, Internet of things
猜你喜欢
Go language learning notes - Gorm use - Gorm processing errors | web framework gin (10)
搞懂fastjson 对泛型的反序列化原理
Mac version PHP installed Xdebug environment (M1 version)
Why does the data center need a set of infrastructure visual management system
postgresql 数据库 timescaledb 函数time_bucket_gapfill()报错解决及更换 license
软件测试的几个关键步骤,你需要知道
蚂蚁庄园安全头盔 7.8蚂蚁庄园答案
yarn入门(一篇就够了)
How to keep accounts of expenses in life
Go语学习笔记 - gorm使用 - gorm处理错误 | Web框架Gin(十)
随机推荐
Qt多线程的多种方法之一 QThread
Why does the data center need a set of infrastructure visual management system
解决pod install报错:ffi is an incompatible architecture
Flask1.1.4 Werkzeug1.0.1 源碼分析:啟動流程
JVM命令之 jstack:打印JVM中线程快照
基于ADAU1452的DSP及DAC音频失真分析
Check point: the core element for enterprises to deploy zero trust network (ztna)
高并发大流量秒杀方案思路
postgresql 数据库 timescaledb 函数time_bucket_gapfill()报错解决及更换 license
Apple CMS V10 template /mxone Pro adaptive film and television website template
话说SQLyog欺骗了我!
牛客小白月赛52 E.分组求对数和(二分&容斥)
Financial risk control practice - decision tree rule mining template
Swagger3 configuration
Cf:c. column swapping [sort + simulate]
PTA ladder game exercise set l2-002 linked list de duplication
vim映射大K
JMeter's own functions are not enough? Why don't you develop one yourself
From "running distractor" to data platform, Master Lu started the road of evolution
A very good JVM interview question article (74 questions and answers)