MCPcopy Create free account
hub / github.com/TheMariday/marimapper / example_usage

Function example_usage

marimapper/pycolmap_tools/database.py:295–426  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

293
294
295def example_usage():
296 import os
297 import argparse
298
299 parser = argparse.ArgumentParser()
300 parser.add_argument("--database_path", default="database.db")
301 args = parser.parse_args()
302
303 if os.path.exists(args.database_path):
304 print("ERROR: database path already exists -- will not modify it.")
305 return
306
307 # Open the database.
308
309 db = COLMAPDatabase.connect(args.database_path)
310
311 # For convenience, try creating all the tables upfront.
312
313 db.create_tables()
314
315 # Create dummy cameras.
316
317 model1, width1, height1, params1 = (
318 0,
319 1024,
320 768,
321 np.array((1024.0, 512.0, 384.0)),
322 )
323 model2, width2, height2, params2 = (
324 2,
325 1024,
326 768,
327 np.array((1024.0, 512.0, 384.0, 0.1)),
328 )
329
330 camera_id1 = db.add_camera(model1, width1, height1, params1)
331 camera_id2 = db.add_camera(model2, width2, height2, params2)
332
333 # Create dummy images.
334
335 image_id1 = db.add_image("image1.png", camera_id1)
336 image_id2 = db.add_image("image2.png", camera_id1)
337 image_id3 = db.add_image("image3.png", camera_id2)
338 image_id4 = db.add_image("image4.png", camera_id2)
339
340 # Create dummy keypoints.
341 #
342 # Note that COLMAP supports:
343 # - 2D keypoints: (x, y)
344 # - 4D keypoints: (x, y, theta, scale)
345 # - 6D affine keypoints: (x, y, a_11, a_12, a_21, a_22)
346
347 num_keypoints = 1000
348 keypoints1 = np.random.rand(num_keypoints, 2) * (width1, height1)
349 keypoints2 = np.random.rand(num_keypoints, 2) * (width1, height1)
350 keypoints3 = np.random.rand(num_keypoints, 2) * (width2, height2)
351 keypoints4 = np.random.rand(num_keypoints, 2) * (width2, height2)
352

Callers 1

database.pyFile · 0.85

Calls 9

blob_to_arrayFunction · 0.85
image_ids_to_pair_idFunction · 0.85
pair_id_to_image_idsFunction · 0.85
connectMethod · 0.80
add_cameraMethod · 0.80
add_imageMethod · 0.80
add_keypointsMethod · 0.80
add_matchesMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected