-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpy_methods.py
47 lines (40 loc) · 2.02 KB
/
py_methods.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
import os
def ply2txt():
fileNum = 0
while fileNum != 9:
filePath = '.\\data\\pointclouds\\'
ls_path = os.listdir(filePath)
fileNum = 0
for filename in ls_path:
if filename[-3:] == "txt":
os.remove(filePath + filename)
else:
fileNum += 1
ls_path = os.listdir(filePath)
for filename in ls_path:
if filename[-5:] == "A.ply":
with open(filePath + filename, 'r+', encoding='utf-8') as file_read:
with open(filePath + filename[:-3] + "txt", 'w', encoding='utf-8') as file_write:
for line in file_read.readlines():
if (line[0].isdigit() or line[0] == "-") and line[:7] != "0 0 0 1":
if filename.split("_")[1] == "rest":
if filename.split("_")[2] == "archi":
file_write.write(line[:-2] + "2" + "\n")
elif filename.split("_")[2] == "nonarchi":
file_write.write(line[:-2] + "3" + "\n")
elif filename.split("_")[1] == "roof":
file_write.write(line[:-2] + "0" + "\n")
elif filename.split("_")[1] == "ground":
file_write.write(line[:-2] + "1" + "\n")
print("CONVERT: " + filename[:-3] + "txt")
def merge_txt():
filePath = '.\\data\\pointclouds\\'
filename_out = 'POINTCLOUDS_preprocessed.txt'
ls_path = os.listdir(filePath)
with open(filePath + filename_out, 'w', encoding='utf-8') as file_write:
for filename in ls_path:
if filename[-5:] == "A.txt":
with open(filePath + filename, 'r+', encoding='utf-8') as file_read:
for line in file_read.readlines():
file_write.write(line)
print("MERGE: POINTCLOUDS_preprocessed.txt")