fontan commited on
Commit
4a5e539
·
1 Parent(s): c2b8483

lightglue

Browse files
colmap_matcher.sh CHANGED
@@ -146,7 +146,7 @@ fi
146
  # LightGlue Feature Matcher
147
  if [ "${matcher_type}" == "lightglue" ]
148
  then
149
- pixi run -e colmap-sp python3 Baselines/colmap/lightglue_matcher.py
150
  colmap matches_importer \
151
  --database_path ${database} \
152
  --match_list_path "${exp_folder_colmap}/matches.txt" \
 
146
  # LightGlue Feature Matcher
147
  if [ "${matcher_type}" == "lightglue" ]
148
  then
149
+ pixi run -e lightglue python3 Baselines/colmap/lightglue_matcher.py --database ${database} --rgb_path ${rgb_path} --feature superpoint
150
  colmap matches_importer \
151
  --database_path ${database} \
152
  --match_list_path "${exp_folder_colmap}/matches.txt" \
lightglue_matcher.py CHANGED
@@ -1,21 +1,13 @@
1
  import sqlite3
2
- from utilities import lightglue_keypoints, lightglue_matching, unrotate_kps_W
3
  import os
4
  import torch
5
  import matplotlib.pyplot as plt
6
  from tqdm import tqdm
7
  import numpy as np
8
  import cv2
9
- import random
10
-
11
- # ==========================================
12
- # CONFIGURATION
13
- # ==========================================
14
- DB_PATH = "/home/alejandro/VSLAM-LAB-NEXT-ITERATION/VSLAM-LAB-Evaluation/demo/SESOKO/sskall-s01/colmap_00000/colmap_database.db"
15
- IMAGE_DIR = "/home/alejandro/VSLAM-LAB-NEXT-ITERATION/VSLAM-LAB-Benchmark/SESOKO/sskall-s01/rgb_0"
16
- FEATURE_TYPE = 'superpoint'
17
- DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
18
- matches_file_path = os.path.join(os.path.dirname(DB_PATH), "matches.txt")
19
 
20
  # ==========================================
21
  # ==========================================
@@ -278,14 +270,30 @@ def plot_matches_from_db(cursor, image_id1, image_id2, image_dir):
278
 
279
  if __name__ == "__main__":
280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  conn, cursor = load_colmap_db(DB_PATH)
282
  cursor.execute("SELECT image_id, name FROM images")
283
  images_info = {row[0]: row[1] for row in cursor.fetchall()}
284
  image_ids = sorted(images_info.keys())
285
- h = 505
286
- w = 607
287
- # plot_matches_from_db(cursor, image_ids[0], image_ids[1], IMAGE_DIR)
288
- # exit(0)
289
 
290
  clean_database(cursor)
291
  conn.commit()
@@ -296,7 +304,7 @@ if __name__ == "__main__":
296
  fname = images_info[id]
297
  path = os.path.join(IMAGE_DIR, fname)
298
 
299
- feats_dict = lightglue_keypoints(path, features='superpoint')
300
 
301
  fts[id] = feats_dict
302
 
 
1
  import sqlite3
2
+ from lightglue_matcher_utilities import lightglue_keypoints, lightglue_matching, unrotate_kps_W
3
  import os
4
  import torch
5
  import matplotlib.pyplot as plt
6
  from tqdm import tqdm
7
  import numpy as np
8
  import cv2
9
+ import argparse
10
+ from pathlib import Path
 
 
 
 
 
 
 
 
11
 
12
  # ==========================================
13
  # ==========================================
 
270
 
271
  if __name__ == "__main__":
272
 
273
+ parser = argparse.ArgumentParser()
274
+
275
+ #DB_PATH = "/home/alejandro/VSLAM-LAB-NEXT-ITERATION/VSLAM-LAB-Evaluation/demo/SESOKO/sskall-s01/colmap_00000/colmap_database.db"
276
+ #IMAGE_DIR = "/home/alejandro/VSLAM-LAB-NEXT-ITERATION/VSLAM-LAB-Benchmark/SESOKO/sskall-s01/rgb_0"
277
+ #FEATURE_TYPE = 'superpoint'
278
+ #DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
279
+ #matches_file_path = os.path.join(os.path.dirname(DB_PATH), "matches.txt")
280
+
281
+ parser.add_argument("--database", type=Path, required=True)
282
+ parser.add_argument("--rgb_path", type=Path, required=True)
283
+ parser.add_argument("--feature", type=str, required=True)
284
+
285
+ args, _ = parser.parse_known_args()
286
+
287
+ DB_PATH = args.database
288
+ IMAGE_DIR = args.rgb_path
289
+ FEATURE_TYPE = args.feature
290
+ DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
291
+ matches_file_path = os.path.join(os.path.dirname(DB_PATH), "matches.txt")
292
+
293
  conn, cursor = load_colmap_db(DB_PATH)
294
  cursor.execute("SELECT image_id, name FROM images")
295
  images_info = {row[0]: row[1] for row in cursor.fetchall()}
296
  image_ids = sorted(images_info.keys())
 
 
 
 
297
 
298
  clean_database(cursor)
299
  conn.commit()
 
304
  fname = images_info[id]
305
  path = os.path.join(IMAGE_DIR, fname)
306
 
307
+ feats_dict, h, w = lightglue_keypoints(path, features='superpoint')
308
 
309
  fts[id] = feats_dict
310
 
lightglue_matcher_utilities.py CHANGED
@@ -191,7 +191,7 @@ def lightglue_keypoints(path_to_image0, features='superpoint', rotations = [0,1,
191
 
192
  # Optional: If you want to retain other keys like 'shape' or 'image_size'
193
  feats_merged['image_size'] = torch.tensor([w, h], device=device).unsqueeze(0)
194
- return feats_merged
195
 
196
  def lightglue_matching(feats0, feats1, plot=False, features='superpoint', path_to_image0=None, path_to_image1=None):
197
  from lightglue import LightGlue, SuperPoint, SIFT
 
191
 
192
  # Optional: If you want to retain other keys like 'shape' or 'image_size'
193
  feats_merged['image_size'] = torch.tensor([w, h], device=device).unsqueeze(0)
194
+ return feats_merged , h, w
195
 
196
  def lightglue_matching(feats0, feats1, plot=False, features='superpoint', path_to_image0=None, path_to_image1=None):
197
  from lightglue import LightGlue, SuperPoint, SIFT