@@ -89,6 +89,21 @@ def read_points3D_text(path):
89
89
xyzs = None
90
90
rgbs = None
91
91
errors = None
92
+ num_points = 0
93
+ with open (path , "r" ) as fid :
94
+ while True :
95
+ line = fid .readline ()
96
+ if not line :
97
+ break
98
+ line = line .strip ()
99
+ if len (line ) > 0 and line [0 ] != "#" :
100
+ num_points += 1
101
+
102
+
103
+ xyzs = np .empty ((num_points , 3 ))
104
+ rgbs = np .empty ((num_points , 3 ))
105
+ errors = np .empty ((num_points , 1 ))
106
+ count = 0
92
107
with open (path , "r" ) as fid :
93
108
while True :
94
109
line = fid .readline ()
@@ -100,14 +115,11 @@ def read_points3D_text(path):
100
115
xyz = np .array (tuple (map (float , elems [1 :4 ])))
101
116
rgb = np .array (tuple (map (int , elems [4 :7 ])))
102
117
error = np .array (float (elems [7 ]))
103
- if xyzs is None :
104
- xyzs = xyz [None , ...]
105
- rgbs = rgb [None , ...]
106
- errors = error [None , ...]
107
- else :
108
- xyzs = np .append (xyzs , xyz [None , ...], axis = 0 )
109
- rgbs = np .append (rgbs , rgb [None , ...], axis = 0 )
110
- errors = np .append (errors , error [None , ...], axis = 0 )
118
+ xyzs [count ] = xyz
119
+ rgbs [count ] = rgb
120
+ errors [count ] = error
121
+ count += 1
122
+
111
123
return xyzs , rgbs , errors
112
124
113
125
def read_points3D_binary (path_to_model_file ):
0 commit comments