@@ -247,6 +247,55 @@ def init_from_colmap(self, root_path: str, observer_pts):
247247 self .default_initialize_from_points (file_pts , observer_pts , file_rgb ,
248248 use_observer_pts = self .conf .initialization .use_observation_points )
249249
250+ def init_from_accumulated_point_cloud (self , pc_path : str , observer_pts ):
251+ """
252+ Initialize gaussians from an accumulated point cloud PLY file.
253+ Similar to init_from_colmap but loads from a given PLY file instead of sparse/0/points3D.txt
254+
255+ Args:
256+ pc_path: Path to the PLY point cloud file
257+ observer_pts: Observer points tensor for scale initialization
258+ """
259+ logger .info (f"Loading accumulated point cloud from { pc_path } ..." )
260+
261+ # Read PLY file
262+ plydata = PlyData .read (pc_path )
263+ vertices = plydata ['vertex' ]
264+
265+ # Extract XYZ coordinates
266+ xyz = np .stack ([
267+ vertices ['x' ],
268+ vertices ['y' ],
269+ vertices ['z' ]
270+ ], axis = 1 ).astype (np .float32 )
271+
272+ # Extract RGB colors (check if they exist)
273+ if 'red' in vertices and 'green' in vertices and 'blue' in vertices :
274+ rgb = np .stack ([
275+ vertices ['red' ],
276+ vertices ['green' ],
277+ vertices ['blue' ]
278+ ], axis = 1 ).astype (np .uint8 )
279+ else :
280+ # If no colors, initialize with random colors
281+ logger .warning ("No RGB data found in point cloud, using random colors" )
282+ rgb = np .random .randint (0 , 256 , size = (len (vertices ), 3 ), dtype = np .uint8 )
283+
284+ # Convert to torch tensors
285+ file_pts = torch .tensor (xyz , dtype = torch .float32 , device = self .device )
286+ file_rgb = torch .tensor (rgb , dtype = torch .uint8 , device = self .device )
287+
288+ logger .info (f"Loaded { len (file_pts )} points from accumulated point cloud" )
289+
290+ # Initialize using the same method as COLMAP
291+ assert file_rgb .dtype == torch .uint8 , "Expecting RGB values to be in [0, 255] range"
292+ self .default_initialize_from_points (
293+ file_pts ,
294+ observer_pts ,
295+ file_rgb ,
296+ use_observer_pts = self .conf .initialization .use_observation_points
297+ )
298+
250299 def init_from_pretrained_point_cloud (self , pc_path : str , set_optimizable_parameters : bool = True ):
251300 data = PlyData .read (pc_path )
252301 num_gaussians = len (data ["vertex" ])
0 commit comments