当前位置:网站首页>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() # 显示
边栏推荐
- Vscode for code completion
- C. colonne Swapping [tri + Simulation]
- VScode进行代码补全
- From "running distractor" to data platform, Master Lu started the road of evolution
- K8s running Oracle
- Why does the data center need a set of infrastructure visual management system
- Qt多线程的多种方法之一 QThread
- Experience of Niuke SQL
- 360织语发布7.0新品 为党政军、央国企打造专属“统一数字工作空间”
- 3531. 哈夫曼树
猜你喜欢
Cf:c. column swapping [sort + simulate]
Introduction to yarn (one article is enough)
高并发大流量秒杀方案思路
如何在Touch Designer 2022版中设置解决Leap Motion不识别的问题?
VScode进行代码补全
【FPGA教程案例14】基于vivado核的FIR滤波器设计与实现
CTFshow--常用姿势
go-microservice-simple(2) go-Probuffer
Understand the deserialization principle of fastjson for generics
SubGHz, LoRaWAN, NB-IoT, 物联网
随机推荐
k8s运行oracle
CMD permanently delete specified folders and files
Flask 1.1.4 werkzeug1.0.1 analyse du code source: processus de démarrage
Subghz, lorawan, Nb IOT, Internet of things
Introduction to the extension implementation of SAP Spartacus checkout process
[FPGA tutorial case 14] design and implementation of FIR filter based on vivado core
进程间通信之共享内存
PTA ladder game exercise set l2-002 linked list de duplication
rt-thread 中对 hardfault 的处理
Go语学习笔记 - gorm使用 - 原生sql、命名参数、Rows、ToSQL | Web框架Gin(九)
【SQL实战】一条SQL统计全国各地疫情分布情况
如何在Touch Designer 2022版中设置解决Leap Motion不识别的问题?
[cloud native] what is the microservice architecture?
Jstat of JVM command: View JVM statistics
JVM监控及诊断工具-命令行篇
Flask1.1.4 Werkzeug1.0.1 源码分析:启动流程
postgresql 数据库 timescaledb 函数time_bucket_gapfill()报错解决及更换 license
蚂蚁庄园安全头盔 7.8蚂蚁庄园答案
Laravel uses Tencent cloud cos5 full tutorial
360织语发布7.0新品 为党政军、央国企打造专属“统一数字工作空间”