-
Notifications
You must be signed in to change notification settings - Fork 0
/
converter.py
56 lines (49 loc) · 1.83 KB
/
converter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sys
import os
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QDialog, QApplication, QFileDialog
from PyQt5.uic import loadUi
from plyfile import PlyData, PlyElement
import open3d as o3d
class MainWindow(QDialog):
def __init__(self):
super(MainWindow, self).__init__()
loadUi("converter.ui", self)
self.filedir = 0
self.browse.clicked.connect(self.browsefiles)
self.convert.clicked.connect(self.pcd_to_ply)
def browsefiles(self):
self.currt_root = os.getcwd()
self.fname = QFileDialog.getOpenFileNames(
self, "Open file", "", "Pointcloud files (*.pcd *.ply)"
)
self.filename.setText(self.fname[0][0])
def pcd_to_ply(self):
select_flag = False
try:
num_of_select_file = len(self.fname[0])
print("select ", num_of_select_file, " files")
select_flag = True
except:
print("Select the file first")
if select_flag == True:
for i in range(num_of_select_file):
pc_filename = self.fname[0][i].split("/")[-1][:-4]
pc_file_dir = self.fname[0][i][: -(len(pc_filename) + 4)]
# without open3d"
# os.chdir(pc_file_dir)
# commad = 'pcl_pcd2ply -format 0 input ' + pc_filename + ".pcd " + pc_filename +".ply"
# os.system(commad)
print("converting...")
pcd = o3d.io.read_point_cloud(self.fname[0][i])
print(pcd)
o3d.io.write_point_cloud(pc_file_dir + pc_filename + ".ply", pcd)
print("convert done")
app = QApplication(sys.argv)
mainwindow = MainWindow()
widget = QtWidgets.QStackedWidget()
widget.addWidget(mainwindow)
widget.setFixedWidth(400)
widget.setFixedHeight(300)
widget.show()
sys.exit(app.exec_())