@@ -964,6 +964,35 @@ def reconstruction_to_ply(
964964 return points_to_ply_string (vertices , point_num_views )
965965
966966
967+ def point_cloud_from_ply (
968+ fp : t .TextIO ,
969+ ) -> t .Tuple [np .ndarray , np .ndarray , np .ndarray , np .ndarray , np .ndarray ]:
970+ """Load point cloud from a PLY file."""
971+ all_lines = fp .read ().splitlines ()
972+ start = all_lines .index ("end_header" ) + 1
973+ lines = all_lines [start :]
974+ n = len (lines )
975+
976+ points = np .zeros ((n , 3 ), dtype = np .float32 )
977+ normals = np .zeros ((n , 3 ), dtype = np .float32 )
978+ colors = np .zeros ((n , 3 ), dtype = np .uint8 )
979+ labels = np .zeros ((n ,), dtype = np .uint8 )
980+ detections = np .zeros ((n ,), dtype = np .uint8 )
981+
982+ for i , row in enumerate (lines ):
983+ words = row .split ()
984+ label = int (words [9 ])
985+ points [i ] = list (map (float , words [0 :3 ]))
986+ normals [i ] = list (map (float , words [3 :6 ]))
987+ colors [i ] = list (map (int , words [6 :9 ]))
988+ labels [i ] = label
989+ if len (words ) == 11 :
990+ detection = int (words [10 ])
991+ detections [i ] = detection
992+
993+ return points , normals , colors , labels , detections
994+
995+
967996def point_cloud_to_ply (
968997 points : np .ndarray ,
969998 normals : np .ndarray ,
0 commit comments