@@ -712,7 +712,7 @@ def load_landmarks(landmark_path: str,
712
712
713
713
return landmarks
714
714
715
- def load_scan (scan_path ):
715
+ def load_scan (scan_path , return_vertex_colors = False ):
716
716
"""
717
717
Load scan given its scan_path using open3d.
718
718
Scan can be defined as:
@@ -725,13 +725,16 @@ def load_scan(scan_path):
725
725
726
726
ext = scan_path .split ("." )[- 1 ]
727
727
ext_extended = f"{ scan_path .split ('.' )[- 2 ]} .{ ext } "
728
- supported_extensions = [".ply" ,".ply.gz" ]
728
+ supported_extensions = [".ply" ,".ply.gz" , ".obj" ]
729
729
730
- if ext == "ply" :
730
+ if ext in [ "ply" , "obj" ] :
731
731
scan = o3d .io .read_triangle_mesh (scan_path )
732
732
scan_vertices = np .asarray (scan .vertices )
733
733
scan_faces = np .asarray (scan .triangles )
734
734
scan_faces = scan_faces if scan_faces .shape [0 ] > 0 else None
735
+ if return_vertex_colors :
736
+ scan_vertex_colors = np .asarray (scan .vertex_colors )
737
+ print (scan_vertex_colors .shape )
735
738
736
739
elif ext_extended == "ply.gz" :
737
740
with gzip .open (scan_path , 'rb' ) as gz_file :
@@ -748,14 +751,19 @@ def load_scan(scan_path):
748
751
scan_vertices = np .asarray (scan .vertices )
749
752
scan_faces = np .asarray (scan .triangles )
750
753
scan_faces = scan_faces if scan_faces .shape [0 ] > 0 else None
754
+ if return_vertex_colors :
755
+ scan_vertex_colors = np .asarray (scan .vertex_colors )
751
756
os .remove (temp_ply_path )
752
757
753
758
else :
754
759
supported_extensions_str = ', ' .join (supported_extensions )
755
760
msg = f"Scan extensions supported: { supported_extensions_str } . Got .{ ext } ."
756
761
raise ValueError (msg )
757
762
758
- return scan_vertices , scan_faces
763
+ if return_vertex_colors :
764
+ return scan_vertices , scan_vertex_colors
765
+ else :
766
+ return scan_vertices , scan_faces
759
767
760
768
def load_fit (path ):
761
769
0 commit comments