Skip to content

Commit

Permalink
Merge pull request #2 from meyerls/meyerls
Browse files Browse the repository at this point in the history
Fixed path error
  • Loading branch information
meyerls authored Nov 30, 2022
2 parents e663baf + 8149944 commit f850eb1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
24 changes: 18 additions & 6 deletions colmap_wrapper/colmap/colmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,28 @@ def __init__(self, project_path: str,
raise ValueError('Colmap project structure: sparse folder (cameras, images, points3d) can not be found')

project_structure = {}
self._dense_base_path = self._project_path.joinpath('dense')

for project_index, sparse_project_path in enumerate(list(self._sparse_base_path.iterdir())):
project_structure.update({project_index: {"sparse": sparse_project_path}})
# Test if path is a file to get number of subprojects. Single Project with no numeric folder
if not all([path.is_dir() for path in self._sparse_base_path.iterdir()]):
project_structure.update({0: {
"project_path": self._project_path,
"sparse": self._sparse_base_path,
"dense": self._dense_base_path}})
else:
# In case of folder with reconstruction number after sparse (multiple projects) (e.g. 0,1,2)
for project_index, sparse_project_path in enumerate(list(self._sparse_base_path.iterdir())):
project_structure.update({project_index: {"sparse": sparse_project_path}})

self._dense_base_path = self._project_path.joinpath('dense')
for project_index, dense_project_path in enumerate(list(self._dense_base_path.iterdir())):
project_structure[project_index].update({"dense": dense_project_path})
for project_index, dense_project_path in enumerate(list(self._dense_base_path.iterdir())):
project_structure[project_index].update({"dense": dense_project_path})

for project_index in project_structure.keys():
project_structure[project_index].update({"project_path": self._project_path})

self.project_list = []
self.model_ids = []

for project_index in project_structure.keys():
self.model_ids.append(project_index)

Expand Down Expand Up @@ -74,7 +86,7 @@ def projects(self, projects):
if __name__ == '__main__':
from colmap_wrapper.visualization import ColmapVisualization

MODE = 'single'
MODE = 'multi'

if MODE == "single":
from colmap_wrapper.data.download import Dataset
Expand Down
29 changes: 15 additions & 14 deletions colmap_wrapper/colmap/colmap_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def __init__(self, project_path: [dict, str],
if not self._dense_base_path.exists():
self._dense_base_path: Path = self._project_path
elif isinstance(project_path, dict):
self._project_path: Path = project_path
self._dense_base_path: Path = self._project_path['dense']
self._sparse_base_path: Path = self._project_path['sparse']
self._project_path: Path = project_path['project_path']
self._dense_base_path: Path = project_path['dense']
self._sparse_base_path: Path = project_path['sparse']
else:
raise ValueError("{}".format(self._project_path))

Expand Down Expand Up @@ -177,17 +177,18 @@ def __read_project_init_file(self):
return {}

def __read_exif_data(self):
try:
for image_idx in self.images.keys():
self.images[image_idx].original_filename: Path = Path(self.project_ini['Basic']['image_path']) / \
self.images[
image_idx].name
with exiftool.ExifToolHelper() as et:
metadata = et.get_metadata(self.images[image_idx].original_filename.__str__())
self.images[image_idx].exifdata = metadata[0]
except exiftool.exceptions.ExifToolExecuteError as error:
# traceback.print_exc()
warnings.warn("Exif Data could not be read.")
if self.__project_ini_path.exists():
try:
for image_idx in self.images.keys():
self.images[image_idx].original_filename: Path = Path(self.project_ini['Basic']['image_path']) / \
self.images[
image_idx].name
with exiftool.ExifToolHelper() as et:
metadata = et.get_metadata(self.images[image_idx].original_filename.__str__())
self.images[image_idx].exifdata = metadata[0]
except exiftool.exceptions.ExifToolExecuteError as error:
# traceback.print_exc()
warnings.warn("Exif Data could not be read.")

def __add_infos(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setuptools.setup(
name='colmap_wrapper',
version='1.1.3',
version='1.1.4',
description='COLMAP Wrapper',
license="MIT",
long_description=long_description,
Expand Down

0 comments on commit f850eb1

Please sign in to comment.