3 Star 4 Fork 2

辰光/双目视觉林木三维重建系统

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
FE.py 9.34 KB
一键复制 编辑 原始数据 按行查看 历史
辰光 提交于 2023-11-06 14:44 . 完整版
#FE.py
import tkinter as tk
from tkinter import *
from ass_choose import *
import cv2
import open3d as o3d
import ass_choose
import ass_shot
import ass_calibrate
import Caliborate_helper
import stereoconfig_040_2
import webbrowser
root = Tk()
file_path = ''
file_text = ''
def callback():
os.system(r'python ass_choose.py')
global file_path
global file_text
if file_path is not None:
with open(file='out.txt', mode='r+', encoding='utf-8') as file:
file_text = file.read()
text1.insert('insert', file_text)
def callback1():
os.system(r'python ass_shot.py')
global file_path
global file_text
if file_path is not None:
with open(file='out.txt', mode='r+', encoding='utf-8') as file:
file_text = file.read()
text1.insert('insert', file_text)
def callback2():
os.system(r'python ass_calibrate.py')
global file_path
global file_text
if file_path is not None:
with open(file='out.txt', mode='r+', encoding='utf-8') as file:
file_text = file.read()
text1.insert('insert', file_text)
def showStereoCamera():
global file_path
global file_text
if file_path is not None:
with open(file='StereoCamera.txt', mode='r+', encoding='utf-8') as file:
file_text = file.read()
text1.insert('insert', file_text)
def showStereoCamera1():
global file_path
global file_text
if file_path is not None:
with open(file='StereoCamera_1.txt', mode='r+', encoding='utf-8') as file:
file_text = file.read()
text1.insert('insert', file_text)
def showshengchengopen1():
ply = o3d.io.read_point_cloud('./double_camera/2_16.ply')
o3d.visualization.draw_geometries([ply])
def showshicha1():
img_path = r"./double_camera/2_1.jpg"
img = cv2.imread(img_path)
cv2.namedWindow('./double_camera/2_1.jpg', 0)
cv2.resizeWindow('./double_camera/2_1.jpg', 500, 500)
cv2.imshow('./double_camera/2_1.jpg', img)
cv2.waitKey()
def showjiaozheng1():
img_path = r"./double_camera/2_check_rectification4.png"
img = cv2.imread(img_path)
cv2.namedWindow('./double_camera/2_check_rectification4.png', 0)
cv2.resizeWindow('./double_camera/2_check_rectification4.png', 1280, 480)
cv2.imshow('./double_camera/2_check_rectification4.png', img)
cv2.waitKey()
def showshengchengopen2():
ply = o3d.io.read_point_cloud('./double_camera/3_16.ply')
o3d.visualization.draw_geometries([ply])
def showshicha2():
img_path = r"./double_camera/3_1.jpg"
img = cv2.imread(img_path)
cv2.namedWindow('./double_camera/3_1.jpg', 0)
cv2.resizeWindow('./double_camera/3_1.jpg', 500, 500)
cv2.imshow('./double_camera/3_1.jpg', img)
cv2.waitKey()
def showjiaozheng2():
img_path = r"./double_camera/3_check_rectification4.png"
img = cv2.imread(img_path)
cv2.namedWindow('./double_camera/3_check_rectification4.png', 0)
cv2.resizeWindow('./double_camera/3_check_rectification4.png', 1280, 480)
cv2.imshow('./double_camera/3_check_rectification4.png', img)
cv2.waitKey()
def showshengchengopen3():
ply = o3d.io.read_point_cloud('./double_camera/4_16.ply')
o3d.visualization.draw_geometries([ply])
def showshicha3():
img_path = r"./double_camera/4_1.jpg"
img = cv2.imread(img_path)
cv2.namedWindow('./double_camera/4_1.jpg', 0)
cv2.resizeWindow('./double_camera/4_1.jpg', 500, 500)
cv2.imshow('./double_camera/4_1.jpg', img)
cv2.waitKey()
def showjiaozheng3():
img_path = r"./double_camera/4_check_rectification4.png"
img = cv2.imread(img_path)
cv2.namedWindow('./double_camera/4_check_rectification4.png', 0)
cv2.resizeWindow('./double_camera/4_check_rectification4.png', 1280, 480)
cv2.imshow('./double_camera/4_check_rectification4.png', img)
cv2.waitKey()
def saveshicha():
new = tkinter.filedialog.asksaveasfilename(title=u'请选择保存视差图的路径', filetypes=[(".jpg", "JPG")])
shutil.copy(os.path.join('./double_camera/1_1.jpg'), os.path.join(new))
def savejiaozheng():
new = tkinter.filedialog.asksaveasfilename(title=u'请选择保存矫正图的路径', filetypes=[(".png", "PNG")])
shutil.copy(os.path.join('./double_camera/1_check_rectification4.png'), os.path.join(new))
def saveshengchengopen():
new = tkinter.filedialog.asksaveasfilename(title=u'请选择保存三维点云文件的路径', filetypes=[(".ply", "PLY")])
shutil.copy(os.path.join('./double_camera/1_16.ply'), os.path.join(new))
def help2():
url = 'https://blog.csdn.net/xiaojinyu2002/article/details/130240076'
webbrowser.open(url, new=1)
root.title("双目视觉林木三维重建系统")
a = tk.Button(root, text="拍照并执行", bg='silver', relief=SOLID)
a.config(command=callback1)
a.config(activebackground='pink')
a.config(activeforeground='green')
a.grid(row=1, column=0, ipadx=102, ipady=5, padx=30, pady=10)
b = tk.Button(root, text="选择的照片执行", bg='silver', relief=SOLID)
b.config(command=callback)
b.config(activebackground='pink')
b.config(activeforeground='green')
b.grid(row=3, column=0, ipadx=90, ipady=5, padx=30, pady=10)
x = tk.Button(root, text="选择标定参数执行", bg='silver', relief=SOLID)
x.config(command=callback2)
x.config(activebackground='pink')
x.config(activeforeground='green')
x.grid(row=5, column=0, ipadx=83, ipady=5, padx=30, pady=10)
c = tk.Button(root, text="查看相机参数", bg='gainsboro', relief=SOLID, command=showStereoCamera)
c.config(activebackground='pink')
c.config(activeforeground='green')
c.grid(row=1, column=1, ipadx=15, ipady=5, padx=30, pady=10)
c1 = tk.Button(root, text="查看相机参数", bg='gainsboro', relief=SOLID, command=showStereoCamera)
c1.config(activebackground='pink')
c1.config(activeforeground='green')
c1.grid(row=3, column=1, ipadx=15, ipady=5, padx=30, pady=10)
c2 = tk.Button(root, text="查看标定参数", bg='gainsboro', relief=SOLID, command=showStereoCamera1)
c2.config(activebackground='pink')
c2.config(activeforeground='green')
c2.grid(row=5, column=1, ipadx=15, ipady=5, padx=30, pady=10)
d = tk.Button(root, text="查看矫正图", bg='gainsboro', relief=SOLID)
d.config(activebackground='pink', activeforeground='green', command=showjiaozheng1)
d.grid(row=1, column=2, ipadx=15, ipady=5, padx=30, pady=10)
d1 = tk.Button(root, text="查看矫正图", bg='gainsboro', relief=SOLID)
d1.config(activebackground='pink', activeforeground='green', command=showjiaozheng2)
d1.grid(row=3, column=2, ipadx=15, ipady=5, padx=30, pady=10)
d2 = tk.Button(root, text="查看矫正图", bg='gainsboro', relief=SOLID)
d2.config(activebackground='pink', activeforeground='green', command=showjiaozheng3)
d2.grid(row=5, column=2, ipadx=15, ipady=5, padx=30, pady=10)
e = tk.Button(root, text="查看视差图", bg='gainsboro', relief=SOLID, command=showshicha1)
e.config(activebackground='pink', activeforeground='green')
e.grid(row=1, column=3, ipadx=15, ipady=5, padx=30, pady=10)
e1 = tk.Button(root, text="查看视差图", bg='gainsboro', relief=SOLID, command=showshicha2)
e1.config(activebackground='pink', activeforeground='green')
e1.grid(row=3, column=3, ipadx=15, ipady=5, padx=30, pady=10)
e2 = tk.Button(root, text="查看视差图", bg='gainsboro', relief=SOLID, command=showshicha3)
e2.config(activebackground='pink', activeforeground='green')
e2.grid(row=5, column=3, ipadx=15, ipady=5, padx=30, pady=10)
f = tk.Button(root, text="查看三维点云", bg='gainsboro', relief=SOLID, command=showshengchengopen1)
f.config(activebackground='pink', activeforeground='green')
f.grid(row=1, column=4, ipadx=15, ipady=5, padx=30, pady=10)
f1 = tk.Button(root, text="查看三维点云", bg='gainsboro', relief=SOLID, command=showshengchengopen2)
f1.config(activebackground='pink', activeforeground='green')
f1.grid(row=3, column=4, ipadx=15, ipady=5, padx=30, pady=10)
f2 = tk.Button(root, text="查看三维点云", bg='gainsboro', relief=SOLID, command=showshengchengopen3)
f2.config(activebackground='pink', activeforeground='green')
f2.grid(row=5, column=4, ipadx=15, ipady=5, padx=30, pady=10)
g = tk.Button(root, text="保存本次执行生成的矫正图", bg='lightgrey', relief=SOLID, command=savejiaozheng)
g.config(activebackground='pink', activeforeground='green')
g.place(x=90, y=360)
h = tk.Button(root, text="保存本次执行生成的视差图", bg='lightgrey', relief=SOLID, command=saveshicha)
h.config(activebackground='pink', activeforeground='green')
h.place(x=280, y=360)
i = tk.Button(root, text="保存本次执行生成的三维点云图", bg='lightgrey', relief=SOLID, command=saveshengchengopen)
i.config(activebackground='pink', activeforeground='green')
i.place(x=470, y=360)
text1 = tk.Text(root, width=95, height=20, bg='whitesmoke', font=('Arial', 12), relief="flat")
text1.place(x=90, y=400)
j2 = tk.Button(root, text="使用手册", bg='lightgrey', relief=SOLID, command=help2)
j2.config(activebackground='pink', activeforeground='green')
j2.place(x=860, y=360)
Label(root, text=" 连接双目摄像机拍照并使用默认标定参数进行双目视觉林木三维重建:").grid(row=0, sticky=W, pady=10)
Label(root, text=" 选择图片并使用默认标定参数进行双目视觉林木三维重建:").grid(row=2, sticky=W, pady=10)
Label(root, text=" 使用手动标定的方法进行三维重建:").grid(row=4, sticky=W, pady=10)
Label(root, text=" 您还可以做出以下操作:").grid(row=6, sticky=W, pady=10)
root.geometry('1050x750')
root.resizable(False, False)
root.mainloop()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/niu-ZUO/ScreenCamera.git
git@gitee.com:niu-ZUO/ScreenCamera.git
niu-ZUO
ScreenCamera
双目视觉林木三维重建系统
master

搜索帮助