ostapagon commited on
Commit
7c39709
·
1 Parent(s): 61ba7d2

Comment more code

Browse files
Files changed (1) hide show
  1. demo/mast3r_demo.py +27 -27
demo/mast3r_demo.py CHANGED
@@ -30,15 +30,15 @@ from dust3r.demo import get_args_parser as dust3r_get_args_parser
30
 
31
  sys.path.append(os.path.join(os.path.dirname(__file__), '../wild-gaussian-splatting/gaussian-splatting'))
32
  sys.path.append(os.path.join(os.path.dirname(__file__), '../wild-gaussian-splatting/src'))
33
- from colmap_dataset_utils import (
34
- inv,
35
- init_filestructure,
36
- save_images_masks,
37
- save_cameras,
38
- save_imagestxt,
39
- save_pointcloud,
40
- save_pointcloud_with_normals
41
- )
42
 
43
  import matplotlib.pyplot as pl
44
 
@@ -150,27 +150,27 @@ def get_3D_model_from_scene(silent, scene_state, min_conf_thr=2, as_pointcloud=F
150
  return _convert_scene_output_to_glb(outfile, rgbimg, pts3d, msk, focals, cams2world, as_pointcloud=as_pointcloud,
151
  transparent_cams=transparent_cams, cam_size=cam_size, silent=silent)
152
 
153
- def save_colmap_scene(scene, save_dir, min_conf_thr=2, clean_depth=False):
154
- cam2world = scene.get_im_poses().detach().cpu().numpy()
155
- world2cam = inv(cam2world) #
156
- principal_points = scene.get_principal_points().detach().cpu().numpy()
157
- focals = scene.get_focals().detach().cpu().numpy()[..., None]
158
- imgs = np.array(scene.imgs)
159
 
160
- pts3d, _, confs = scene.get_dense_pts3d(clean_depth=clean_depth)
161
- pts3d = [i.detach().reshape(imgs[0].shape) for i in pts3d] #
162
 
163
- masks = to_numpy([c > min_conf_thr for c in to_numpy(confs)])
164
 
165
- # move
166
- mask_images = True
167
 
168
- save_path, images_path, masks_path, sparse_path = init_filestructure(save_dir)
169
- save_images_masks(imgs, masks, images_path, masks_path, mask_images)
170
- save_cameras(focals, principal_points, sparse_path, imgs_shape=imgs.shape)
171
- save_imagestxt(world2cam, sparse_path)
172
- save_pointcloud_with_normals(imgs, pts3d, masks, sparse_path)
173
- return save_path
174
 
175
  def get_reconstructed_scene(outdir, model, device, silent, image_size, current_scene_state,
176
  filelist, optim_level, lr1, niter1, lr2, niter2, min_conf_thr, matching_conf_thr,
@@ -220,7 +220,7 @@ def get_reconstructed_scene(outdir, model, device, silent, image_size, current_s
220
  os.makedirs(base_colmapdata_dir, exist_ok=True)
221
  colmap_data_dir = get_next_dir(base_colmapdata_dir)
222
  #
223
- save_colmap_scene(scene, colmap_data_dir, min_conf_thr, clean_depth)
224
 
225
  if current_scene_state is not None and \
226
  current_scene_state.outfile_name is not None:
 
30
 
31
  sys.path.append(os.path.join(os.path.dirname(__file__), '../wild-gaussian-splatting/gaussian-splatting'))
32
  sys.path.append(os.path.join(os.path.dirname(__file__), '../wild-gaussian-splatting/src'))
33
+ # from colmap_dataset_utils import (
34
+ # inv,
35
+ # init_filestructure,
36
+ # save_images_masks,
37
+ # save_cameras,
38
+ # save_imagestxt,
39
+ # save_pointcloud,
40
+ # save_pointcloud_with_normals
41
+ # )
42
 
43
  import matplotlib.pyplot as pl
44
 
 
150
  return _convert_scene_output_to_glb(outfile, rgbimg, pts3d, msk, focals, cams2world, as_pointcloud=as_pointcloud,
151
  transparent_cams=transparent_cams, cam_size=cam_size, silent=silent)
152
 
153
+ # def save_colmap_scene(scene, save_dir, min_conf_thr=2, clean_depth=False):
154
+ # cam2world = scene.get_im_poses().detach().cpu().numpy()
155
+ # world2cam = inv(cam2world) #
156
+ # principal_points = scene.get_principal_points().detach().cpu().numpy()
157
+ # focals = scene.get_focals().detach().cpu().numpy()[..., None]
158
+ # imgs = np.array(scene.imgs)
159
 
160
+ # pts3d, _, confs = scene.get_dense_pts3d(clean_depth=clean_depth)
161
+ # pts3d = [i.detach().reshape(imgs[0].shape) for i in pts3d] #
162
 
163
+ # masks = to_numpy([c > min_conf_thr for c in to_numpy(confs)])
164
 
165
+ # # move
166
+ # mask_images = True
167
 
168
+ # save_path, images_path, masks_path, sparse_path = init_filestructure(save_dir)
169
+ # save_images_masks(imgs, masks, images_path, masks_path, mask_images)
170
+ # save_cameras(focals, principal_points, sparse_path, imgs_shape=imgs.shape)
171
+ # save_imagestxt(world2cam, sparse_path)
172
+ # save_pointcloud_with_normals(imgs, pts3d, masks, sparse_path)
173
+ # return save_path
174
 
175
  def get_reconstructed_scene(outdir, model, device, silent, image_size, current_scene_state,
176
  filelist, optim_level, lr1, niter1, lr2, niter2, min_conf_thr, matching_conf_thr,
 
220
  os.makedirs(base_colmapdata_dir, exist_ok=True)
221
  colmap_data_dir = get_next_dir(base_colmapdata_dir)
222
  #
223
+ # save_colmap_scene(scene, colmap_data_dir, min_conf_thr, clean_depth)
224
 
225
  if current_scene_state is not None and \
226
  current_scene_state.outfile_name is not None: