This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
GenerateRueMadameDataSet.py
74 lines (61 loc) · 2.52 KB
/
GenerateRueMadameDataSet.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
\file GenerateRueMadameDataSet.py
\brief Script to generate the rue madame dataset.
\copyright Copyright (c) 2019 Visual Computing group of Ulm University,
Germany. See the LICENSE file at the top-level directory of
this distribution.
\author pedro hermosilla (pedro-1.hermosilla-casajus@uni-ulm.de)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
import sys
import math
import argparse
import time
import os
from os import listdir
from os.path import isfile, join
import numpy as np
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
MCCNN_DIR = os.path.join(BASE_DIR, 'MCCNN')
sys.path.append(os.path.join(MCCNN_DIR, 'utils'))
from PyUtils import save_model
from ply_reader import read_points_binary_ply
def process_node(pts, nodeIter):
if len(pts) > 500000:
ptMax = np.amax(pts, axis = 0)
ptMin = np.amin(pts, axis = 0)
aabbSize = ptMax - ptMin
midPt = (ptMax + ptMin)*0.5
axis = np.where(aabbSize == np.amax(aabbSize))
axis = axis[0][0]
ptsLeft = np.array([pt for pt in pts if pt[axis] < midPt[axis]])
ptsRight = np.array([pt for pt in pts if pt[axis] >= midPt[axis]])
print("Processing intermediate node")
print(len(pts))
print(len(ptsLeft))
print(len(ptsRight))
print()
maxPtLeft = ptMax
maxPtLeft[axis] = midPt[axis]
minPtRight = ptMin
minPtRight[axis] = midPt[axis]
nodeIter = process_node(ptsLeft, nodeIter)
return process_node(ptsRight, nodeIter)
else:
save_model(args.srcFolder+"/RueMadame_"+str(nodeIter), pts)
print("Saving leaf node")
print(nodeIter)
print()
nodeIter += 1
return nodeIter
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Script to generate the rue madame dataset.')
parser.add_argument('--srcFolder', default='RueMadame', help='Source folder with the models (default: RueMadame)')
args = parser.parse_args()
plyFiles = [join(args.srcFolder+"/", f) for f in listdir(args.srcFolder+"/") if isfile(join(args.srcFolder+"/", f)) and f.endswith('.ply')]
nodeIter = 0
for currPly in plyFiles:
print(currPly)
currPts = read_points_binary_ply(currPly)
print(len(currPts))
currPts = np.array([[cPt[0], cPt[1], cPt[2]] for cPt in currPts])
nodeIter = process_node(currPts, nodeIter)