Skip to content

Commit 03f084b

Browse files
committed
Merge branch 's2025_EstCal' of https://github.com/krishauser/GEMstack into s2025_EstCal
2 parents 577d49e + 4431f7f commit 03f084b

15 files changed

Lines changed: 390 additions & 7 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
center: [573.37109375, 363.700927734375]
2-
focal: [684.8333129882812, 684.6096801757812, 1.0]
2+
focal: [684.8333129882812, 684.6096801757812]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sam_vit_h.pth
2+
3+
!.gitignore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 4122ea18abe1831b99abbadce91362571a9b5158
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
data=$1
2+
3+
wget -c -O sam_vit_h.pth https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
4+
5+
echo 'running segmentation...'
6+
python3 segment-anything scripts/amg.py --checkpoint sam_vit_h.pth --model-type vit_h --input $data/images --output $data/masks/ --stability-score-thresh 0.9 --box-nms-thresh 0.5 --stability-score-offset 0.9
7+
8+
echo 'reprocess segmentation...'
9+
python3 CalibAnything/processed_mask.py -i $data/masks -o $data/processed_masks/
10+
11+
echo 'running calibration...'
12+
CalibAnything/bin/run_lidar2camera $data/calib.json
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"cam_K": {
3+
"rows": 3,
4+
"cols": 3,
5+
"data": [
6+
[1180.753804, 0.000000, 934.859447],
7+
[0.000000, 1177.034929, 607.266974],
8+
[0.000000, 0.000000 , 1.000000 ]
9+
]
10+
},
11+
"cam_dist": {
12+
"cols": 5,
13+
"data": [-0.244851, 0.082024, 0.000429, -0.001245, 0.000000]
14+
},
15+
"T_lidar_to_cam":{
16+
"rows": 4,
17+
"cols": 4,
18+
"data": [
19+
[ 0.72 , -0.694, 0.014, 0.12],
20+
[-0.166, -0.191, -0.967, 0.09],
21+
[ 0.673, 0.694, -0.253, -1.17],
22+
[ 0.0 , 0.0 , 0.0 , 1.0 ]
23+
]
24+
},
25+
"img_folder": "images",
26+
"mask_folder": "processed_masks",
27+
"pc_folder": "pc",
28+
"img_format": ".png",
29+
"pc_format": ".pcd",
30+
"file_name": [
31+
"000000",
32+
"000001",
33+
"000002",
34+
"000003",
35+
"000004"
36+
],
37+
"params": {
38+
"min_plane_point_num": 2000,
39+
"cluster_tolerance": 0.25,
40+
"search_num": 4000,
41+
"search_range": {
42+
"rot_deg": 5,
43+
"trans_m": 0.5
44+
},
45+
"point_range":{
46+
"top": 0.4,
47+
"bottom": 1.0
48+
},
49+
"down_sample":{
50+
"is_valid": true,
51+
"voxel_m": 0.05
52+
},
53+
"thread": {
54+
"is_multi_thread": true,
55+
"num_thread": 4
56+
}
57+
}
58+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
3+
!.gitignore
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
3+
!.gitignore
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
3+
!.gitignore
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#%%
2+
#%%
3+
import numpy as np
4+
import open3d as o3d
5+
import os
6+
import argparse
7+
8+
def npz_to_pcd(input_dir, output_dir, data_key='arr_0'):
9+
# Create output directory if it doesn't exist
10+
os.makedirs(output_dir, exist_ok=True)
11+
12+
# Iterate over all .npz files in the input directory
13+
for npz_file in os.listdir(input_dir):
14+
if npz_file.endswith(".npz"):
15+
npz_path = os.path.join(input_dir, npz_file)
16+
output_pcd_path = os.path.join(output_dir, npz_file.replace('.npz', '.pcd'))
17+
18+
try:
19+
# Load data from .npz file
20+
data = np.load(npz_path)
21+
if data_key not in data:
22+
print(f"Skipping {npz_file}: Key '{data_key}' not found.")
23+
continue
24+
25+
point_cloud_np = data[data_key]
26+
27+
# Validate shape (Nx3 for XYZ, Nx6 for XYZRGB, etc.)
28+
if point_cloud_np.ndim != 2 or point_cloud_np.shape[1] < 3:
29+
print(f"Skipping {npz_file}: Invalid shape {point_cloud_np.shape}.")
30+
continue
31+
32+
# Create Open3D point cloud object
33+
pcd = o3d.geometry.PointCloud()
34+
35+
# Assign points (required: Nx3 array)
36+
pcd.points = o3d.utility.Vector3dVector(point_cloud_np[:, :3])
37+
38+
# Optionally assign colors (if available, e.g., Nx6 array with RGB)
39+
if point_cloud_np.shape[1] >= 6:
40+
# RGB values (assuming they are stored as 0-255 integers)
41+
colors = point_cloud_np[:, 3:6] / 255.0 # Normalize to [0, 1] for Open3D
42+
pcd.colors = o3d.utility.Vector3dVector(colors)
43+
44+
# Save to .pcd (supports ASCII or binary)
45+
o3d.io.write_point_cloud(output_pcd_path, pcd, write_ascii=True)
46+
print(f"Converted: {npz_file} -> {output_pcd_path}")
47+
48+
except Exception as e:
49+
print(f"Failed to convert {npz_file}: {str(e)}")
50+
51+
if __name__ == "__main__":
52+
parser = argparse.ArgumentParser(description="Convert .npz to .pcd using Open3D")
53+
parser.add_argument("--input_dir", type=str, required=True, help="Input directory with .npz files")
54+
parser.add_argument("--output_dir", type=str, required=True, help="Output directory for .pcd files")
55+
parser.add_argument("--data_key", type=str, default='points', help="Key for point cloud data in .npz files")
56+
args = parser.parse_args()
57+
58+
npz_to_pcd(args.input_dir, args.output_dir, args.data_key)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit dca509fe793f601edb92606367a655c15ac00fdf

0 commit comments

Comments
 (0)