colmap / pycolmap

Python bindings for COLMAP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pycolmap.MapImageIdImage keys() function is not iterable?

yarden-grin opened this issue · comments

Hello,
I am trying to automatically list the image names registered for a reconstruction.
I can see them under the 'name' index for items inside the 'images' index of a reconstruction when debugging.
To try to list these I was trying to iterate over the images object (of class pycolmap.MapImageIdImage) but it seems this is not iterable. This class has a keys() function which is also not iterable.

pycolmap version is 0.3.0

Did you try this?

names = [im.name for im in reconstruction.values()]

Did you try this?

names = [im.name for im in reconstruction.values()]

It would actually need to be names = [im.name for im in reconstruction.images.values()] but this doesn't work.
The errors is also very uninformative RuntimeError: Caught an unknown exception!

Sorry, indeed meant to write this, which should work. Can you try the 0.4.0 tag? Are you building from source or using the pip wheels?

Sorry, indeed meant to write this, which should work. Can you try the 0.4.0 tag? Are you building from source or using the pip wheels?

I am using pip, for some reason it does not detect the version 0.4.0. I am running python 3.8.16 in my environment.

Even with pip install pycolmap==0.4.0 —upgrade ?

Even with pip install pycolmap==0.4.0 —upgrade ?

ERROR: Could not find a version that satisfies the requirement pycolmap==0.4.0 (from versions: 0.1.0, 0.2.0, 0.3.0)
ERROR: No matching distribution found for pycolmap==0.4.0

pip version is pip-23.2.1

In 0.4.0 we deprecated wheels built for MacOS 10 so you indeed need to build from source in this case. If the crash still occurs in 0.4.0, can you let us know which of the following instructions fails here:

images = list(reconstruction.images.values())
image = images[0]
name = image.name

In 0.4.0 we deprecated wheels built for MacOS 10 so you indeed need to build from source in this case. If the crash still occurs in 0.4.0, can you let us know which of the following instructions fails here:

images = list(reconstruction.images.values())
image = images[0]
name = image.name

I'm actually running MacOS 14. I am trying to build from source but am having some difficulties I am not able to resolve.

[ 50%] Building CXX object CMakeFiles/pycolmap.dir/main.cc.o
      clang: error: no such file or directory: 'NOTFOUND'
      make[2]: *** [CMakeFiles/pycolmap.dir/main.cc.o] Error 1
      make[1]: *** [CMakeFiles/pycolmap.dir/all] Error 2
      make: *** [all] Error 2

I gave up on this, and did a workaround that works for me:

buffer = StringIO()
sys.stdout = buffer
print(reconstruction.images)
print_str = buffer.getvalue()
sys.stdout = sys.__stdout__
pattern = pattern = r'name="([^"]+)"'
images = re.findall(pattern, print_str)

Sorry that this is causing you so much trouble. We don't yet have wheels for MacOS 14 as there's no such runner available in the GitHub CI, and I doubt that earlier wheels will work - so building from source is the only option. I'm not able to help resolving your issue without the full build log.

I think that the new macOS wheels should be compatible with OS 14. They can be downloaded from https://github.com/colmap/pycolmap/actions/runs/7397410117 or on PyPI in a few days.