MCPcopy
hub / github.com/cvg/Hierarchical-Localization / read_model

Function read_model

hloc/utils/read_write_model.py:421–446  ·  view source on GitHub ↗
(path, ext="")

Source from the content-addressed store, hash-verified

419
420
421def read_model(path, ext=""):
422 # try to detect the extension automatically
423 if ext == "":
424 if detect_model_format(path, ".bin"):
425 ext = ".bin"
426 elif detect_model_format(path, ".txt"):
427 ext = ".txt"
428 else:
429 try:
430 cameras, images, points3D = read_model(os.path.join(path, "model/"))
431 logger.warning(
432 "This SfM file structure was deprecated in hloc v1.1")
433 return cameras, images, points3D
434 except FileNotFoundError:
435 raise FileNotFoundError(
436 f"Could not find binary or text COLMAP model at {path}")
437
438 if ext == ".txt":
439 cameras = read_cameras_text(os.path.join(path, "cameras" + ext))
440 images = read_images_text(os.path.join(path, "images" + ext))
441 points3D = read_points3D_text(os.path.join(path, "points3D") + ext)
442 else:
443 cameras = read_cameras_binary(os.path.join(path, "cameras" + ext))
444 images = read_images_binary(os.path.join(path, "images" + ext))
445 points3D = read_points3D_binary(os.path.join(path, "points3D") + ext)
446 return cameras, images, points3D
447
448
449def write_model(cameras, images, points3D, path, ext=".bin"):

Callers 5

create_reference_sfmFunction · 0.90
scale_sfm_imagesFunction · 0.90
mainFunction · 0.85
mainFunction · 0.85

Calls 8

detect_model_formatFunction · 0.85
read_cameras_textFunction · 0.85
read_images_textFunction · 0.85
read_points3D_textFunction · 0.85
read_cameras_binaryFunction · 0.85
read_images_binaryFunction · 0.85
read_points3D_binaryFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected