@@ -76,6 +76,26 @@ def blurScore(path):
76
76
magnitude_spectrum = np .abs (f_transform_shifted )
77
77
return np .percentile (magnitude_spectrum , 95 )
78
78
79
+ def point_cloud_data_frame_to_ply (df , out_fn ):
80
+ with open (out_fn , 'wt' ) as f :
81
+ f .write ('\n ' .join ([
82
+ 'ply' ,
83
+ 'format ascii 1.0' ,
84
+ 'element vertex %d' % len (df ),
85
+ 'property float x' ,
86
+ 'property float y' ,
87
+ 'property float z' ,
88
+ 'property uint8 red' ,
89
+ 'property uint8 green' ,
90
+ 'property uint8 blue' ,
91
+ 'end_header'
92
+ ]) + '\n ' )
93
+ for _ , row in df .iterrows ():
94
+ r = []
95
+ for prop in 'xyz' : r .append (row [prop ])
96
+ for prop in 'rgb' : r .append (int (row [prop ]))
97
+ f .write (' ' .join ([str (v ) for v in r ]) + '\n ' )
98
+
79
99
def convert_json_taichi_to_nerfstudio (d ):
80
100
import numpy as np
81
101
def transform_camera (c ):
@@ -102,7 +122,8 @@ def transform_camera(c):
102
122
"w" : c ['camera_width' ],
103
123
"h" : c ['camera_height' ],
104
124
"aabb_scale" : 16 ,
105
- 'frames' : []
125
+ "frames" : [],
126
+ "ply_file_path" : "./sparse_pc.ply"
106
127
}
107
128
cam_id = json .dumps (params , sort_keys = True )
108
129
if cam_id not in by_camera :
@@ -455,6 +476,9 @@ def write_colmap_csv(data, fn):
455
476
for row in data :
456
477
f .write (' ' .join ([str (c ) for c in row ])+ '\n ' )
457
478
479
+ # splatfacto point cloud format
480
+ point_cloud_data_frame_to_ply (merged_df , f"{ args .output } /sparse_pc.ply" )
481
+
458
482
write_colmap_csv (c_points , f"{ fake_colmap } /points3D.txt" )
459
483
write_colmap_csv (c_images , f"{ fake_colmap } /images.txt" )
460
484
write_colmap_csv (c_cameras , f"{ fake_colmap } /cameras.txt" )
0 commit comments