MCPcopy Create free account
hub / github.com/XiaoBaiiiiii/colmap-pcd / example_usage

Function example_usage

scripts/python/database.py:235–355  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

233
234
235def example_usage():
236 import os
237 import argparse
238
239 parser = argparse.ArgumentParser()
240 parser.add_argument("--database_path", default="database.db")
241 args = parser.parse_args()
242
243 if os.path.exists(args.database_path):
244 print("ERROR: database path already exists -- will not modify it.")
245 return
246
247 # Open the database.
248
249 db = COLMAPDatabase.connect(args.database_path)
250
251 # For convenience, try creating all the tables upfront.
252
253 db.create_tables()
254
255 # Create dummy cameras.
256
257 model1, width1, height1, params1 = \
258 0, 1024, 768, np.array((1024., 512., 384.))
259 model2, width2, height2, params2 = \
260 2, 1024, 768, np.array((1024., 512., 384., 0.1))
261
262 camera_id1 = db.add_camera(model1, width1, height1, params1)
263 camera_id2 = db.add_camera(model2, width2, height2, params2)
264
265 # Create dummy images.
266
267 image_id1 = db.add_image("image1.png", camera_id1)
268 image_id2 = db.add_image("image2.png", camera_id1)
269 image_id3 = db.add_image("image3.png", camera_id2)
270 image_id4 = db.add_image("image4.png", camera_id2)
271
272 # Create dummy keypoints.
273 #
274 # Note that COLMAP supports:
275 # - 2D keypoints: (x, y)
276 # - 4D keypoints: (x, y, theta, scale)
277 # - 6D affine keypoints: (x, y, a_11, a_12, a_21, a_22)
278
279 num_keypoints = 1000
280 keypoints1 = np.random.rand(num_keypoints, 2) * (width1, height1)
281 keypoints2 = np.random.rand(num_keypoints, 2) * (width1, height1)
282 keypoints3 = np.random.rand(num_keypoints, 2) * (width2, height2)
283 keypoints4 = np.random.rand(num_keypoints, 2) * (width2, height2)
284
285 db.add_keypoints(image_id1, keypoints1)
286 db.add_keypoints(image_id2, keypoints2)
287 db.add_keypoints(image_id3, keypoints3)
288 db.add_keypoints(image_id4, keypoints4)
289
290 # Create dummy matches.
291
292 M = 50

Callers 1

database.pyFile · 0.85

Calls 8

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

Tested by

no test coverage detected