Skip to content

Commit ab90593

Browse files
yuepanyuepan
yuepan
authored and
yuepan
committed
support replica
1 parent fd5f159 commit ab90593

21 files changed

+121
-63
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ __pycache__/
55
*.txt
66
*.ply
77
*.bin
8-
*.pth
8+
*.pth
9+
./experiments/
10+
./data/

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ For the sake of efficiency, we sacrifice a bit mapping quality to use a 50cm lea
245245
<img src="https://user-images.githubusercontent.com/34207278/216335116-45273ef9-adb8-4f03-9e58-c5ca60b03081.png" width="70%" />
246246
</p>
247247

248+
<p align="center">
249+
<img src="https://user-images.githubusercontent.com/34207278/217082027-efe272bb-ff6e-49b3-bb69-6d0a32c64a45.png" width="70%" />
250+
</p>
251+
248252
**Newer College**
249253

250254
<p align="center">
@@ -257,24 +261,32 @@ For the sake of efficiency, we sacrifice a bit mapping quality to use a 50cm lea
257261
<img src="https://user-images.githubusercontent.com/34207278/212333973-ad1a0c14-550f-4266-902f-08c33f9f79c1.png" width="70%" />
258262
</p>
259263

260-
**RGB-D**
261-
262-
<p align="center">
263-
<img src="https://user-images.githubusercontent.com/34207278/206718688-a8bfb786-6439-435b-a225-c596aef9ab64.png" width="70%" />
264-
</p>
265264

266265
**Wild Place Forests**
267266

268267
<p align="center">
269268
<img src="https://user-images.githubusercontent.com/34207278/207911217-c27a52c9-7233-4db9-a1fd-3487e59e6529.png" width="70%" />
270269
</p>
271270

272-
**Office**
271+
272+
**IPB Office**
273273

274274
<p align="center">
275275
<img src="https://user-images.githubusercontent.com/34207278/216360654-9b0a8bda-6a98-4db1-aa25-1c58080a4585.png" width="70%" />
276276
</p>
277277

278+
**ICL Living Room**
279+
280+
<p align="center">
281+
<img src="https://user-images.githubusercontent.com/34207278/206718688-a8bfb786-6439-435b-a225-c596aef9ab64.png" width="70%" />
282+
</p>
283+
284+
**Replica**
285+
286+
<p align="center">
287+
<img src="https://user-images.githubusercontent.com/34207278/217082679-319d220a-de1f-4f30-ac14-438b4fe8942a.png" width="70%" />
288+
</p>
289+
278290

279291
</details>
280292

config/kitti/kitti_batch.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ optimizer:
5353
weight_decay: 1e-7 # l2 regularization
5454
eval:
5555
wandb_vis_on: False # log to wandb or not
56+
o3d_vis_on: True # visualize the mapping or not
5657
vis_freq_iters: 5000 # reconstruct the mesh every x iterations
5758
save_freq_iters: 10000 # save the model and octree every x iterations
5859
mesh_freq_frame: 1
5960
mc_res_m: 0.1 # reconstruction marching cubes resolution
60-
mc_mask_on: True
61+
mc_with_octree: True # querying sdf only in certain levels of the octree
6162
mc_vis_level: 1
6263
save_map: False # save the sdf map or not

config/kitti/kitti_incre_reg.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ optimizer:
5353
weight_decay: 1e-7 # l2 regularization
5454
eval:
5555
wandb_vis_on: False # log to wandb or not
56+
o3d_vis_on: True # visualize the mapping or not
5657
vis_freq_iters: 0
5758
save_freq_iters: 10000 # save the model and octree every x iterations
5859
mesh_freq_frame: 5 # reconstruct the mesh every x frames
5960
mc_res_m: 0.1 # reconstruction marching cubes resolution
60-
mc_mask_on: True
61+
mc_with_octree: True # querying sdf only in certain levels of the octree
6162
mc_vis_level: 2
6263
save_map: False # save the sdf map or not

config/kitti/kitti_incre_replay.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ optimizer:
5353
weight_decay: 1e-7 # l2 regularization
5454
eval:
5555
wandb_vis_on: False # log to wandb or not
56+
o3d_vis_on: True # visualize the mapping or not
5657
vis_freq_iters: 0
5758
save_freq_iters: 10000 # save the model and octree every x iterations
5859
mesh_freq_frame: 5 # reconstruct the mesh every x frames
5960
mc_res_m: 0.1 # reconstruction marching cubes resolution
60-
mc_mask_on: True
61+
mc_with_octree: True # querying sdf only in certain levels of the octree
6162
mc_vis_level: 2
6263
save_map: False # save the sdf map or not

config/maicity/maicity_batch.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ optimizer:
5353
weight_decay: 1e-7 # l2 regularization
5454
eval:
5555
wandb_vis_on: False # log to wandb or not
56+
o3d_vis_on: True # visualize the mapping or not
5657
vis_freq_iters: 5000 # reconstruct the mesh every x iterations
5758
save_freq_iters: 10000 # save the model and octree every x iterations
5859
mesh_freq_frame: 1
5960
mc_res_m: 0.1 # reconstruction marching cubes resolution
60-
mc_mask_on: True
61+
mc_with_octree: False # querying sdf in the map bbx
6162
mc_vis_level: 1 # mask the voxels used for marching cubes reconstruction according to the octree level
6263
save_map: False # save the sdf map or not

config/maicity/maicity_incre_reg.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ optimizer:
5353
weight_decay: 0 # l2 regularization
5454
eval:
5555
wandb_vis_on: False # log to wandb or not
56+
o3d_vis_on: True # visualize the mapping or not
5657
vis_freq_iters: 0
5758
save_freq_iters: 0 # save the model and octree every x iterations
5859
mesh_freq_frame: 5 # reconstruct the mesh every x frames
5960
mc_res_m: 0.2 # reconstruction marching cubes resolution
60-
mc_mask_on: True
61+
mc_with_octree: False # querying sdf in the map bbx
6162
mc_vis_level: 2
6263
save_map: False # save the sdf map or not

config/maicity/maicity_incre_replay.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ optimizer:
5353
weight_decay: 0 # l2 regularization
5454
eval:
5555
wandb_vis_on: False # log to wandb or not
56+
o3d_vis_on: True # visualize the mapping or not
5657
vis_freq_iters: 0
5758
save_freq_iters: 0 # save the model and octree every x iterations
5859
mesh_freq_frame: 5 # reconstruct the mesh every x frames
5960
mc_res_m: 0.2 # reconstruction marching cubes resolution
60-
mc_mask_on: True
61+
mc_with_octree: False # querying sdf in the map bbx
6162
mc_vis_level: 2
6263
save_map: False # save the sdf map or not

config/ncd/ncd_batch.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ optimizer:
5353
weight_decay: 1e-7 # l2 regularization
5454
eval:
5555
wandb_vis_on: False # log to wandb or not
56+
o3d_vis_on: True # visualize the mapping or not
5657
vis_freq_iters: 5000 # reconstruct the mesh every x iterations
5758
save_freq_iters: 10000 # save the model and octree every x iterations
5859
mesh_freq_frame: 1
5960
mc_res_m: 0.1 # reconstruction marching cubes resolution
60-
mc_mask_on: True
61+
mc_with_octree: True # querying sdf only in certain levels of the octree
6162
mc_vis_level: 1
6263
save_map: False # save the sdf map or not

config/ncd/ncd_incre_reg.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ optimizer:
5353
weight_decay: 1e-7 # l2 regularization
5454
eval:
5555
wandb_vis_on: False # log to wandb or not
56+
o3d_vis_on: True # visualize the mapping or not
5657
vis_freq_iters: 0
5758
save_freq_iters: 10000 # save the model and octree every x iterations
5859
mesh_freq_frame: 5 # reconstruct the mesh every x frames
5960
mc_res_m: 0.1 # reconstruction marching cubes resolution
60-
mc_mask_on: True
61+
mc_with_octree: True # querying sdf only in certain levels of the octree
6162
mc_vis_level: 2
6263
save_map: False # save the sdf map or not

config/ncd/ncd_incre_replay.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ optimizer:
5353
weight_decay: 1e-7 # l2 regularization
5454
eval:
5555
wandb_vis_on: False # log to wandb or not
56+
o3d_vis_on: True # visualize the mapping or not
5657
vis_freq_iters: 0
5758
save_freq_iters: 10000 # save the model and octree every x iterations
5859
mesh_freq_frame: 5 # reconstruct the mesh every x frames
5960
mc_res_m: 0.1 # reconstruction marching cubes resolution
60-
mc_mask_on: True
61+
mc_with_octree: True # querying sdf only in certain levels of the octree
6162
mc_vis_level: 2
6263
save_map: False # save the sdf map or not

config/rgbd/rgbd_batch.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ optimizer:
5353
weight_decay: 1e-7 # l2 regularization
5454
eval:
5555
wandb_vis_on: False # log to wandb or not
56+
o3d_vis_on: True # visualize the mapping or not
5657
vis_freq_iters: 5000 # reconstruct the mesh every x iterations
5758
save_freq_iters: 10000 # save the model and octree every x iterations
5859
mesh_freq_frame: 1
59-
mc_res_m: 0.02 # reconstruction marching cubes resolution
60-
mc_mask_on: True
60+
mc_res_m: 0.01 # reconstruction marching cubes resolution
61+
mc_with_octree: True # querying sdf in the map bbx
6162
mc_vis_level: 2
6263
save_map: False # save the sdf map or not

config/rgbd/rgbd_incre_reg.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ optimizer:
5353
weight_decay: 1e-7 # l2 regularization
5454
eval:
5555
wandb_vis_on: False # log to wandb or not
56+
o3d_vis_on: True # visualize the mapping or not
5657
vis_freq_iters: 0 # reconstruct the mesh every x iterations
5758
save_freq_iters: 10000 # save the model and octree every x iterations
5859
mesh_freq_frame: 5 # reconstruct the mesh every x frames
5960
mc_res_m: 0.02 # reconstruction marching cubes resolution
60-
mc_mask_on: True
61+
mc_with_octree: True # querying sdf in the map bbx
6162
mc_vis_level: 2
6263
save_map: False # save the sdf map or not

config/rgbd/rgbd_incre_replay.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ optimizer:
5353
weight_decay: 1e-7 # l2 regularization
5454
eval:
5555
wandb_vis_on: False # log to wandb or not
56+
o3d_vis_on: True # visualize the mapping or not
5657
vis_freq_iters: 0 # reconstruct the mesh every x iterations
5758
save_freq_iters: 10000 # save the model and octree every x iterations
5859
mesh_freq_frame: 5 # reconstruct the mesh every x frames
5960
mc_res_m: 0.02 # reconstruction marching cubes resolution
60-
mc_mask_on: True
61+
mc_with_octree: True # querying sdf in the map bbx
6162
mc_vis_level: 2
6263
save_map: False # save the sdf map or not

dataset/rgbd_to_kitti_format.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
from tqdm import tqdm
33
import argparse
44
import re
5-
import json
65
import os
76
import numpy as np
8-
9-
from utils.tools import load_from_json
7+
import json
8+
import shutil
109

1110
def rgbd_to_kitti_format(args):
1211

1312
ply_path = os.path.join(args.output_root, "rgbd_ply")
1413
os.makedirs(ply_path, exist_ok=True)
1514

1615
# get pose
17-
poses_mat = load_poses(args.pose_file, with_head = False) # with_head = True for open3d provided Redwood dataset
1816
pose_kitti_format_path = os.path.join(args.output_root, "poses.txt")
19-
write_poses_kitti_format(poses_mat, pose_kitti_format_path)
17+
if args.already_kitti_format_pose:
18+
shutil.copyfile(args.pose_file, pose_kitti_format_path) # don't directly copy, may have some issues
19+
else:
20+
poses_mat = load_poses(args.pose_file, with_head = False) # with_head = True for open3d provided Redwood dataset
21+
write_poses_kitti_format(poses_mat, pose_kitti_format_path)
2022

2123
# get an example image
2224
depth_img_files = sorted(os.listdir(args.depth_img_folder), key=alphanum_key)
@@ -36,8 +38,10 @@ def rgbd_to_kitti_format(args):
3638
# W=640, H=480, fx=fy=525.0, cx=319.5, cy=239.5
3739
print("Default intrinsic for PrimeSense used")
3840
intrinsic = o3d.camera.PinholeCameraIntrinsic(o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault)
41+
# use this extrinsic matrix to rotate the image since frames captured with RealSense camera are upside down
42+
extrinsic = np.array([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
3943
else:
40-
if args.is_focal_file: # load the focal length only txt file
44+
if args.is_focal_file: # load the focal length only txt file # This is used for NeuralRGBD dataset
4145
focal = load_focal_length(args.intrinsic_file)
4246
print("Focal length:", focal)
4347
intrinsic.set_intrinsics(height=H,
@@ -47,6 +51,8 @@ def rgbd_to_kitti_format(args):
4751
cx=(W-1.)/2.,
4852
cy=(H-1.)/2.)
4953
depth_scale = 1000.
54+
# use this extrinsic matrix to rotate the image since frames captured with RealSense camera are upside down
55+
extrinsic = np.array([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
5056

5157
else:
5258
with open(args.intrinsic_file, 'r') as infile: # load intrinsic json file
@@ -58,9 +64,8 @@ def rgbd_to_kitti_format(args):
5864
cx=cam["cx"],
5965
cy=cam["cy"])
6066
depth_scale = cam["scale"]
67+
extrinsic = np.eye(4) # this is used for Replica dataset
6168

62-
# use this extrinsic matrix to rotate the image since frames captured with RealSense camera are upside down
63-
extrinsic = np.array([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
6469

6570
# get point cloud
6671
frame_count = 0
@@ -69,9 +74,10 @@ def rgbd_to_kitti_format(args):
6974
depth_path = os.path.join(args.depth_img_folder, depth_path)
7075
print(color_path)
7176
print(depth_path)
77+
7278
im_color = o3d.io.read_image(color_path)
73-
im_depth = o3d.io.read_image(depth_path)
74-
im_rgbd = o3d.geometry.RGBDImage.create_from_color_and_depth(im_color, im_depth, depth_scale = depth_scale, depth_trunc = args.max_depth_m)
79+
im_depth = o3d.io.read_image(depth_path)
80+
im_rgbd = o3d.geometry.RGBDImage.create_from_color_and_depth(im_color, im_depth, depth_scale = depth_scale, depth_trunc = args.max_depth_m, convert_rgb_to_intensity=False) # not just gray
7581
im_pcd = o3d.geometry.PointCloud.create_from_rgbd_image(im_rgbd, intrinsic, extrinsic)
7682

7783
if args.vis_on:
@@ -101,6 +107,15 @@ def alphanum_key(s):
101107
"""
102108
return [int(x) if x.isdigit() else x for x in re.split('([0-9]+)', s)]
103109

110+
def load_from_json(filename):
111+
"""Load a dictionary from a JSON filename.
112+
Args:
113+
filename: The filename to load from.
114+
"""
115+
assert filename.suffix == ".json"
116+
with open(filename, encoding="UTF-8") as file:
117+
return json.load(file)
118+
104119
def load_focal_length(filepath):
105120
file = open(filepath, "r")
106121
return float(file.readline())
@@ -147,6 +162,9 @@ def parser_json_sdf_studio_format(json_file):
147162
parser.add_argument('--is_focal_file', type=str2bool, nargs='?', default=True, \
148163
help="is the input intrinsic file a txt file containing only the focus length (as the Neural RGBD data format)\
149164
or the json file containing all the intrinsic parameters (as the Replica format)")
165+
parser.add_argument('--already_kitti_format_pose', type=str2bool, nargs='?', default=False, \
166+
help="is the input pose file already in KITTI pose format (also as the Replica format)\
167+
or the input pose file is in a 4dim transformation form (as the Neural RGBD data format)")
150168
parser.add_argument('--vis_on', type=str2bool, nargs='?', default=False)
151169
args = parser.parse_args()
152170

model/feature_octree.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import torch
2-
import torch.nn.functional as F
32
import torch.nn as nn
43

5-
import math
64
import time
75
from tqdm import tqdm
86
import kaolin as kal
97
import numpy as np
10-
from torch.autograd import grad
118

129
from functools import partial
1310
from collections import defaultdict
1411

1512
from utils.config import SHINEConfig
16-
from utils.loss import sdf_bce_loss
1713

1814
# TODO: polish the codes
1915

scripts/convert_rgbd_to_kitti_format.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ root_path=xxx/data/neural_rgbd_data
44
sequence_name=green_room
55
base_path=${root_path}/${sequence_name}
66

7+
# For NeuralRGBD dataset, set is_focal_file to True, and already_kitti_format_pose to False
8+
# For Replica dataset, set is_focal_file to False, and already_kitti_format_pose to True
9+
710
command="python3 ./dataset/rgbd_to_kitti_format.py
811
--output_root ${base_path}_kitti_format
912
--depth_img_folder ${base_path}/depth_filtered/
1013
--rgb_img_folder ${base_path}/images/
1114
--intrinsic_file ${base_path}/focal.txt
1215
--pose_file ${base_path}/poses.txt
1316
--is_focal_file True
17+
--already_kitti_format_pose False
1418
--vis_on False"
1519

1620
echo "Convert RGBD dataset to KITTI format"

shine_incre.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def run_shine_mapping_incremental():
162162

163163
# reconstruction by marching cubes
164164
if processed_frame == 0 or (processed_frame+1) % config.mesh_freq_frame == 0:
165+
print("Begin mesh reconstruction from the implicit map")
165166
vis_mesh = True
166167
# print("Begin reconstruction from implicit mapn")
167168
mesh_path = run_path + '/mesh/mesh_frame_' + str(frame_id+1) + ".ply"

0 commit comments

Comments
 (0)