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

Method __init__

hloc/extract_features.py:173–199  ·  view source on GitHub ↗
(self, root, conf, paths=None)

Source from the content-addressed store, hash-verified

171 }
172
173 def __init__(self, root, conf, paths=None):
174 self.conf = conf = SimpleNamespace(**{**self.default_conf, **conf})
175 self.root = root
176
177 if paths is None:
178 paths = []
179 for g in conf.globs:
180 paths += glob.glob(
181 (Path(root) / '**' / g).as_posix(), recursive=True)
182 if len(paths) == 0:
183 raise ValueError(f'Could not find any image in root: {root}.')
184 paths = sorted(set(paths))
185 self.names = [Path(p).relative_to(root).as_posix() for p in paths]
186 logger.info(f'Found {len(self.names)} images in root {root}.')
187 else:
188 if isinstance(paths, (Path, str)):
189 self.names = parse_image_lists(paths)
190 elif isinstance(paths, collections.Iterable):
191 self.names = [p.as_posix() if isinstance(p, Path) else p
192 for p in paths]
193 else:
194 raise ValueError(f'Unknown format for path argument {paths}.')
195
196 for name in self.names:
197 if not (root / name).exists():
198 raise ValueError(
199 f'Image {name} does not exists in root: {root}.')
200
201 def __getitem__(self, idx):
202 name = self.names[idx]

Callers

nothing calls this directly

Calls 1

parse_image_listsFunction · 0.85

Tested by

no test coverage detected