Skip to content

pycolmap.import_images() fails with TypeError due to WindowsPath object being passed instead of str #3688

@sdnavin

Description

@sdnavin

While running the ns-process-data command with --matcher-type NN-ratio, the process fails during the pycolmap.import_images() call. This happens because WindowsPath objects are passed instead of str, which pycolmap strictly requires.

📋 Command
ns-process-data images --data C:\Users\turbo\Videos\s4\recv3\360v2\images --output-dir my_scene --matcher-type NN-ratio

🧵 Full Traceback
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
...
File "nerfstudio/hloc/hloc/reconstruction.py", line 45, in import_images
pycolmap.import_images(
TypeError: import_images(): incompatible function arguments. The following argument types are supported:
1. (database_path: str, image_path: str, camera_mode: pycolmap._core.CameraMode = CameraMode.AUTO, image_names: list[str] = [], options: pycolmap._core.ImageReaderOptions = ImageReaderOptions())

Invoked with: WindowsPath('my_scene/colmap/sparse/0/database.db'), WindowsPath('my_scene/images'), CameraMode.SINGLE; kwargs: image_list=[], options=ImageReaderOptions(...)

💡 Suggested Fix
In file:
nerfstudio/hloc/hloc/reconstruction.py
Line ~45 should cast paths to strings before passing them to pycolmap.import_images():

❌ Current:
pycolmap.import_images(
database,
image_dir,
camera_mode,
image_names=image_list,
options=image_options,
)
✅ Suggested Fix:
pycolmap.import_images(
str(database),
str(image_dir),
camera_mode,
image_names=image_list,
options=image_options,
)
🧪 Environment
OS: Windows 10
Python: 3.10
Nerfstudio version: latest (as of July 14, 2025)
Installed via: pip in virtualenv
pycolmap version: 0.6.0
ns-process-data used with --matcher-type NN-ratio

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions