Coder Social home page Coder Social logo

3dom-fbk / deep-image-matching Goto Github PK

View Code? Open in Web Editor NEW
298.0 12.0 31.0 334.82 MB

Multiview matching with deep-learning and hand-crafted local features for COLMAP and other SfM software. Supports high-resolution formats and images with rotations. Both CLI and GUI are supported.

Home Page: https://3dom-fbk.github.io/deep-image-matching/

License: BSD 3-Clause "New" or "Revised" License

Python 92.25% Batchfile 0.05% Shell 0.14% Jupyter Notebook 4.20% Dockerfile 0.10% HTML 2.03% JavaScript 0.95% CSS 0.27%
colmap deep-learning image-matching keypoint-matching keypoints local-feature-matching multiview slam structure-from-motion high-resolution-image

deep-image-matching's Introduction

Static Badge Static Badge Static Badge Static Badge

Static Badge Static Badge GitHub Release Static Badge

DEEP-IMAGE-MATCHING

SIFT DISK IMAGES ORIENTATION DENSE WITH ROMA
SIFT SUPERGLUE

Multivew matcher for SfM software. Support both deep-learning based and hand-crafted local features and matchers and export keypoints and matches directly in a COLMAP database or to Agisoft Metashape by importing the reconstruction in Bundler format. Now, it supports both OpenMVG and MicMac. Feel free to collaborate!

While dev branch is more frequently updated, master is the default more stable branch and is updated from dev less frequently. If you are looking for the newest developments, please switch to dev.

For how to use DIM, check the Documentation (updated for the master branch).

Please, note that deep-image-matching is under active development and it is still in an experimental stage. If you find any bug, please open an issue.

Key features:

  • Multiview
  • Large format images
  • SOTA deep-learning and hand-crafted features
  • Support for image rotations
  • Compatibility with several SfM software
  • Support image retrieval with deep-learning local features
Supported Extractors Supported Matchers
✓ SuperPoint ✓ Lightglue (with Superpoint, Disk, and ALIKED)
✓ DISK ✓ SuperGlue (with Superpoint)
☐ Superpoint free ✓ Nearest neighbor (with KORNIA Descriptor Matcher)
✓ ALIKE ✓ LoFTR (only GPU)
✓ ALIKED ✓ SE2-LoFTR (no tiling and only GPU)
✓ KeyNet + OriNet + HardNet8 ✓ RoMa
✓ DeDoDe (only GPU) ☐ GlueStick
✓ SIFT (from Opencv)
✓ ORB (from Opencv)
Supported SfM software
✓ COLMAP
✓ OpenMVG
✓ MICMAC
✓ Agisoft Metashape
✓ Software that supports bundler format

Colab demo and notebooks

Want to run on a sample dataset? ➡️ Open In Colab

Want to run on your images? ➡️ Open In Colab

DIM can also be utilized as a library instead of being executed through the Command Line Interface (refer to the Usage Instructions). For an illustrative example, please see notebooks/sfm_pipeline.ipynb.

Local Installation

For installing deep-image-matching, first create a conda environment:

conda create -n deep-image-matching python=3.9
conda activate deep-image-matching
pip install --upgrade pip

Clone the repository and install deep-image-matching in editable mode:

git clone https://github.com/3DOM-FBK/deep-image-matching.git
cd deep-image-matching
pip install -e .

Install pycolmap (optional):

pip install pycolmap==0.6.1

Pycolmap is optional to run reconstruction directly in DIM. If pycolmap is not available, matches will be written both in a h5 and colmap database for later processing with COLMAP GUI or API, or other processing.

For more information, check the documentation.

Docker Installation

If you prefer using Docker, first, build the image:

docker build --tag deep-image-matching .

Note that the first time you run the command, it will take a while to download the base image and install all the dependencies.

Once the image is built, you can run it with the following commands. On Linux:

docker run --name run-deep-image-matching --mount type=bind,source=/home/username/data,target=/workspace/data --gpus all -it deep-image-matching

On Windows (please use Powershell):

docker run --name run-deep-image-matching --mount type=bind,source=D:\data,target=/workspace/data --gpus all -it deep-image-matching

replace /home/username/data (on Linux) or D:\data (on Winows) with the desired path for mounting a shared volume between the local OS and the docker container. Make sure to use absolute paths. This folder will be used to store alll the input data (images) and outputs.

Include the --detach option to run the container in background and/or --rm to remove container on exit.

Once the container is running, you can then open the repo cloned inside the container directly in VSCode using ctrl+alt+O and selecting the option "attach to running container" (make sure to have the Docker extension installed in VSCode), then enjoy!

If you face any issues, especially on Linux when using the gpus all setting, please refer to the documentation.

Usage instructions

Use the following command to see all the available options from the CLI:

python main.py --help

For example, to run the matching with SuperPoint and LightGlue on a dataset, you can use the following command:

python main.py --dir assets/example_cyprus --pipeline superpoint+lightglue

The --dir parameter defines the processing directory, where all the results will be saved. This directory must constain a subfolder named images in which all the images must be stored. We currentely do not support image retrieval from multiple directories or subdirectories, but we may add this feature in the future.

The --pipeline parameter defines the combaination of local feature extractor and matcher.

For all the usage instructions and configurations, refer to the documenation or check the example notebooks.

Advanced usage

For advanced usage, please refer to the documentation and/or check the scripts directory.

Merging databases with different local features

To run the matching with different local features and/or matchers and marging together the results, you can use scripts in the ./scripts directory for merging the COLMAP databases.

python ./join_databases.py --help
python ./join_databases.py --input path/to/dir/with/databases --output path/to/output/dir

Exporting the solution to Metashape

To export the solution to Metashape, you can export the COLMAP database to Bundler format and then import it into Metashape. This can be done from Metashape GUI, by first importing the images and then use the function Import Cameras (File -> Import -> Import Cameras) to select Bundler file (e.g., bundler.out) and the image list file (e.g., bundler_list.txt).

Alternatevely, you can use the export_to_metashape.py script to automatically create a Metashape project from a reconstruction saved in Bundler format. The script export_to_metashape.py takes as input the solution in Bundler format and the images and it exports the solution to Metashape. It requires to install Metashape as a Python module in your environment and to have a valid license. Please, refer to the instructions at https://github.com/franioli/metashape.

How to contribute

Any contribution to this repo is really welcome! If you want to contribute to the project, please, check the contributing guidelines.

To Do List:

See the TODO list for the list of features and improvements that are planned for the future.

References

If you find the repository useful for your work consider citing the papers:

@article{morelli2024_deep_image_matching,
  AUTHOR = {Morelli, L. and Ioli, F. and Maiwald, F. and Mazzacca, G. and Menna, F. and Remondino, F.},
  TITLE = {DEEP-IMAGE-MATCHING: A TOOLBOX FOR MULTIVIEW IMAGE MATCHING OF COMPLEX SCENARIOS},
  JOURNAL = {The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences},
  VOLUME = {XLVIII-2/W4-2024},
  YEAR = {2024},
  PAGES = {309--316},
  DOI = {10.5194/isprs-archives-XLVIII-2-W4-2024-309-2024}
}
@article{morelli2022photogrammetry,
  title={PHOTOGRAMMETRY NOW AND THEN--FROM HAND-CRAFTED TO DEEP-LEARNING TIE POINTS--},
  author={Morelli, Luca and Bellavia, Fabio and Menna, Fabio and Remondino, Fabio},
  journal={The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences},
  volume={48},
  pages={163--170},
  year={2022},
  publisher={Copernicus GmbH}
}
@article{ioli2024,
  title={Deep Learning Low-cost Photogrammetry for 4D Short-term Glacier
Dynamics Monitoring},
  author={Ioli, Francesco and Dematteis, Nicolò and Giordan, Daniele and Nex, Francesco and Pinto Livio},
  journal={PFG – Journal of Photogrammetry, Remote Sensing and Geoinformation Science},
  year={2024},
  DOI = {10.1007/s41064-023-00272-w}
}

Depending on the options used, consider citing the corresponding work of:

deep-image-matching's People

Contributors

3dom-fbk avatar elliestath avatar franioli avatar gperda avatar kauevestena avatar lcmrl avatar nneilsutherland avatar tudipffmgt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deep-image-matching's Issues

16bit images

Could be nice to not convert 16bit images to 8bit images, and check if DL local features works better

Removed "feature_path" and "im_path" from hdf5 feature file

When writing "features.h5" after the extraction, the ExtractorBase class was saving in the h5 file also "feature_path" and "im_path" as datatasets.
I commented it because it was leading to errors when not using matching by tiles.

Commented lines:

  1. extractor_base.py - extract(): ln. 149-150, ln. 158-159
  2. h5.py - get_features(): ln. 53-54, ln 58-59

Small question about camera model (multi focal length)

Hi, thanks for the great support for multi focal length, it works fine.
And I have some small questions about camera model part.

  1. Why does model simple-radial set default value K1=0.1?
    Meanwhile, model opencv sets default value K1=K2=0.
    https://github.com/3DOM-FBK/deep-image-matching/blob/master/src/deep_image_matching/io/h5_to_db.py#L159

  2. Manually editing cameras.yaml makes users can set everything, but it is not a easy usage when calculating large image set (>hundreds).
    Now I have written a small program to scan the file names in a folder.
    So my actually process is: 1. Put different focal length images in seperated sub-folders. 2. Run the scan program to get the file names in every sub-folders. 3. Move all the images in sub-folders to the images folder. 4. Edit cameras.yaml to fill in the file names.
    If ImageMatching class could scan sub-folders, it will be no need to do these steps. This makes all the images use a same camera model, which is not so flexible, but we can change it using COLMAP UI later.
    Of course, this is not a functional question, just for easy using for large data set.

Thank you.

Make detector-free matchers (loftr, se2-loftr, roma) really working for multi-camera

All the detector-free matchers (loftr, se2-loftr, roma) work only on image pairs. Therefore, these approaches currentely return matches on each pair of images with multiplicity (track length) of 2. We should think of some approaches to track the same matched feature on all the images and increase robustness of dense reconstruction.

A possible approach is to implement some kind of binning of the features, as Dmytro Mishkin did in
https://github.com/ducha-aiki/imc2023-kornia-starter-pack

keep matching score/confidence (if available)

Now all the matcher classes return only the image coordinates of the matched keypoints. We should keep track also of the matching score/confidence/certainty (especially for dense/semi-dense matchers such as RoMa)

No exif data available for image

when i run python main.py --dir assets/test --pipeline superpoint+lightglue,I always get this info on terminal :

2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000000.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000010.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000020.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000030.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000040.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000050.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000060.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000070.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000080.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000090.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000100.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000110.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000120.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000130.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000140.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000150.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000160.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000170.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000180.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000190.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000200.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000210.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000220.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000230.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000240.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000250.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000260.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000270.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000280.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000290.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000300.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000310.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000320.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000330.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000340.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000350.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000360.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000370.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000380.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000390.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000400.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000410.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000420.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000430.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000440.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000450.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000460.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000470.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000480.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000490.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000500.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000510.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000520.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000530.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000540.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000550.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000560.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000570.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000580.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000590.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000600.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000610.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000620.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000630.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000640.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000650.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000660.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000670.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000680.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000690.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000700.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000710.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000720.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000730.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000740.jpg (this will probably not affect the matching).
2024-05-28 13:46:09 | [INFO    ] No exif data available for image 86e0b31c214c0a2eb5d50b3ca395479c_000750.jpg (this will probably not affect the matching).

what's this message mean? and how to avoid it?

Will it affect the output?

thanks a lot.

How to check the matching result?

Hi, I found some problem when processing my own data (large images).
When downsampled to 2K, position calcultion result is right. When downsampled to 2K, and processing with tiling preselection (tile_size is set to half of default, try_match_full_images set true), still OK.
But when downsampled to 4K, the result is wrong. When downsampled to 4K, and processing with tiling preselection (try_match_full_images set true or false both tested), still wrong.
It seems that processing of large images may have problem.

I guess if matching result is not good, and I want to debug this.
Now I can find image pairs with features in folder results_superpoint+lightglue_matching_lowres_quality_high/debug.
But there is no matching result for debug. I have read the documents and still do not know how to check the matching results.
Is there a way to check this result?

Update: I have found show_matches.py in the root folder, but I cannot run it as the usage.
Error message is:
ModuleNotFoundError: No module named 'cv2'
I have tried to run pip install opencv-python, and got message:

Requirement already satisfied: opencv-python in c:\users\up2u\miniconda3\envs\deep-image-matching\lib\site-packages (4.9.0.80)
Requirement already satisfied: numpy>=1.17.0 in c:\users\up2u\miniconda3\envs\deep-image-matching\lib\site-packages (from opencv-python) (1.26.3)

Thank you.

Some options not working

All local features work with TileSelection.PRESELECTION option in the config.py file a part for SuperPoint+SuperGlue and keynetaffnethardnet+kornia_matcher. TileSelection.NONE at the moment doesn't work with SuperPoint+LightGlue, DISK+LightGlue and ALIKED+LightGlue

Processing stucks after ~1000 images at BA

HI!

Thank you very much for a wonderfull job you did! I've tried to run a reconstruction
python ./main.py --config superpoint+lightglue --images images --outs out --strategy sequential --overlap 2 --force
and everything is fine when I run it for a dataset with <1000 images. However, I run it for a dataset with 2000 images it takes significantly more time for BA, especially after 1000 images.
I tried to lower the quality here "quality": Quality.HIGH -> "quality": Quality.LOW but got
2024-01-04 16:08:21 | [INFO ] Matching features...
2024-01-04 16:08:21 | [INFO ]
3%|█▉ | 114/4545 [00:37<23:58, 3.08it/s]
Traceback (most recent call last):
File "C:\Users\yaroslav\Desktop\deep-image-matching\main.py", line 405, in
main()
File "C:\Users\yaroslav\Desktop\deep-image-matching\main.py", line 238, in main
match_path = img_matching.match_pairs(feature_path)
File "C:\Users\yaroslav\Desktop\deep-image-matching\src\deep_image_matching\image_matching.py", line 311, in match_pairs
matches = self._matcher.match(
File "C:\Users\yaroslav\Desktop\deep-image-matching\src\deep_image_matching\matchers\matcher_base.py", line 279, in match
self._matches = self._match_by_tile(
File "C:\Users\yaroslav\Desktop\deep-image-matching\src\deep_image_matching\matchers\matcher_base.py", line 380, in _match_by_tile
correspondences = self._match_pairs(feats0_tile, feats1_tile)
File "C:\Users\yaroslav\anaconda3\envs\slam\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "C:\Users\yaroslav\Desktop\deep-image-matching\src\deep_image_matching\matchers\lightglue.py", line 71, in _match_pairs
match_res = self._matcher({"image0": feats0, "image1": feats1})
File "C:\Users\yaroslav\anaconda3\envs\slam\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "C:\Users\yaroslav\anaconda3\envs\slam\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "C:\Users\yaroslav\Desktop\deep-image-matching\src\deep_image_matching\thirdparty\LightGlue\lightglue\lightglue.py", line 463, in forward
return self._forward(data)
File "C:\Users\yaroslav\Desktop\deep-image-matching\src\deep_image_matching\thirdparty\LightGlue\lightglue\lightglue.py", line 529, in _forward
if self.check_if_stop(token0[..., :m, :], token1[..., :n, :], i, m + n):
File "C:\Users\yaroslav\Desktop\deep-image-matching\src\deep_image_matching\thirdparty\LightGlue\lightglue\lightglue.py", line 613, in check_if_stop
confidences = torch.cat([confidences0, confidences1], -1)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 1 but got size 0 for tensor number 1 in the list.

cannot find file when run in Colab

hello, when I run [colab_run_from_bash_example.ipynb] in Colab, here is an error:

Snipaste_2024-04-05_16-51-52
Snipaste_2024-04-05_16-53-31
Snipaste_2024-04-05_16-54-43
As you can see, install deep-image-matching and run python3 deep-image-matching/main.py --help is OK,
but when I run
python3 ./deep-image-matching/main.py \ --dir ./deep-image-matching/assets/pytest \ --pipeline sift+kornia_matcher \ --skip_reconstruction
here is an error:

2024-04-05 09:03:55 | [INFO    ] Running image matching with the following configuration:
2024-04-05 09:03:55 | [INFO    ]   Image folder: deep-image-matching/assets/pytest/images
2024-04-05 09:03:55 | [INFO    ]   Output folder: deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high
2024-04-05 09:03:55 | [INFO    ]   Number of images: 3
2024-04-05 09:03:55 | [INFO    ]   Matching strategy: matching_lowres
2024-04-05 09:03:55 | [INFO    ]   Image quality: HIGH
2024-04-05 09:03:55 | [INFO    ]   Tile selection: NONE
2024-04-05 09:03:55 | [INFO    ]   Feature extraction method: sift
2024-04-05 09:03:55 | [INFO    ]   Matching method: kornia_matcher
2024-04-05 09:03:55 | [INFO    ]   Geometric verification: PYDEGENSAC
2024-04-05 09:03:55 | [INFO    ]   CUDA available: True
2024-04-05 09:03:55 | [INFO    ] Low resolution matching, generating pairs ..
Loaded SuperPoint model
2024-04-05 09:03:56 | [INFO    ] Extracting features from downsampled images...
2024-04-05 09:03:57 | [INFO    ] Matching downsampled images...
2024-04-05 09:03:58 | [INFO    ] Found 3 pairs.
2024-04-05 09:03:58 | [INFO    ] Extracting features with sift...
2024-04-05 09:03:58 | [INFO    ] sift configuration: 
{'name': 'sift'}
2024-04-05 09:04:00 | [INFO    ] Features extracted!
2024-04-05 09:04:00 | [INFO    ] Matching features with kornia_matcher...
2024-04-05 09:04:00 | [INFO    ] kornia_matcher configuration: 
{'match_mode': 'smnn', 'name': 'kornia_matcher', 'th': 0.85}
2024-04-05 09:04:00 | [INFO    ] Matching features...
2024-04-05 09:04:00 | [INFO    ] 
2024-04-05 09:04:00 | [WARNING ] Cannot find scores in deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/features.h5
2024-04-05 09:04:00 | [WARNING ] Cannot find scores in deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/features.h5
2024-04-05 09:04:00 | [WARNING ] Cannot find scores in deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/features.h5
2024-04-05 09:04:00 | [WARNING ] Cannot find scores in deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/features.h5
2024-04-05 09:04:00 | [WARNING ] Cannot find scores in deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/features.h5
2024-04-05 09:04:00 | [WARNING ] Cannot find scores in deep-image-matching/assets/pytest/results_sift+kornia_matcher_matching_lowres_quality_high/features.h5
Downloading: "https://github.com/cvg/LightGlue/releases/download/v0.1_arxiv/superpoint_v1.pth" to /root/.cache/torch/hub/checkpoints/superpoint_v1.pth
100%|██████████| 4.96M/4.96M [00:00<00:00, 98.3MB/s]
Downloading: "https://github.com/cvg/LightGlue/releases/download/v0.1_arxiv/superpoint_lightglue.pth" to /root/.cache/torch/hub/checkpoints/superpoint_lightglue_v0-1_arxiv.pth
100%|██████████| 45.3M/45.3M [00:00<00:00, 226MB/s]
100%|██████████| 3/3 [00:00<00:00,  3.16it/s]
100%|██████████| 3/3 [00:00<00:00,  3.49it/s]
100%|██████████| 3/3 [00:01<00:00,  2.46it/s]
100%|██████████| 3/3 [00:01<00:00,  2.67it/s]
Traceback (most recent call last):
  File "/content/./deep-image-matching/main.py", line 58, in <module>
    with open(config.general["camera_options"], "r") as file:
FileNotFoundError: [Errno 2] No such file or directory: './config/cameras.yaml'
---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
[<ipython-input-5-935a973addd6>](https://localhost:8080/#) in <cell line: 1>()
----> 1 get_ipython().run_cell_magic('bash', '', 'python3 ./deep-image-matching/main.py \\\n  --dir ./deep-image-matching/assets/pytest \\\n  --pipeline sift+kornia_matcher \\\n  --skip_reconstruction\n')

4 frames
[/usr/local/lib/python3.10/dist-packages/google/colab/_shell.py](https://localhost:8080/#) in run_cell_magic(self, magic_name, line, cell)
    332     if line and not cell:
    333       cell = ' '
--> 334     return super().run_cell_magic(magic_name, line, cell)
    335 
    336 

[/usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py](https://localhost:8080/#) in run_cell_magic(self, magic_name, line, cell)
   2471             with self.builtin_trap:
   2472                 args = (magic_arg_s, cell)
-> 2473                 result = fn(*args, **kwargs)
   2474             return result
   2475 

[/usr/local/lib/python3.10/dist-packages/IPython/core/magics/script.py](https://localhost:8080/#) in named_script_magic(line, cell)
    140             else:
    141                 line = script
--> 142             return self.shebang(line, cell)
    143 
    144         # write a basic docstring:

<decorator-gen-103> in shebang(self, line, cell)

[/usr/local/lib/python3.10/dist-packages/IPython/core/magic.py](https://localhost:8080/#) in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

[/usr/local/lib/python3.10/dist-packages/IPython/core/magics/script.py](https://localhost:8080/#) in shebang(self, line, cell)
    243             sys.stderr.flush()
    244         if args.raise_error and p.returncode!=0:
--> 245             raise CalledProcessError(p.returncode, cell, output=out, stderr=err)
    246 
    247     def _run_script(self, p, cell, to_close):

CalledProcessError: Command 'b'python3 ./deep-image-matching/main.py \\\n  --dir ./deep-image-matching/assets/pytest \\\n  --pipeline sift+kornia_matcher \\\n  --skip_reconstruction\n'' returned non-zero exit status 1.

can you help me? thank you so much

Show matches result error with RootSIFT local features

Thanks for your work!
I use the colmap gui to visual the matches,and result is right,which means the match process(database.db) is right.But I use the show_matches.py to visual the matches. I get wrong result.
After debugging,I find that some keypoints have negative coordinate values.,which makes me confused.
How can I solve this problem?

image
image
image

Improve Tiler with adaptive tile grid computation

Now you have to statically define the number of tiles and the Tiler compute the limits of the tiling grid. We should also give the possibility to set the tile length and compute the tiling grid accordingly and introduce an auto mode to automatically compute the tiling grid based on the available GPU memory and the chosen extractor/matcher approach.

e.g., use Kornia approaches for extracting patches https://kornia.readthedocs.io/en/latest/contrib.html#image-patches

I found the matching speed is slow ( use superpoint+lightglue )

First of all, I would like to thank you for your work. However, when I was using it to process 1k images of 4k resolution, I noticed that the matching speed was very slow, around 3 pairs/s. I saw that you have mentioned speed improvements in your todo, and if there is any progress, I will follow up promptly.

Configuration management

Define a better way to manage configuation parameters.
Each Extractor/Matcher should have its default configuration defined within the class itselft (before the init method), but the user should be able to update it by defined a custom configuration at the program beginning.
Also, a list of pre-defined combinations of allowed extractors and matchers must be defined and the user can choose only between them

Merging databases - issues on raw matches

Merged matches from different local features are written in COLMAP databases both as raw and verified matches. If verified matches are deleted in COLMAP GUI and then run only geometric verification, COLMAP crashes (COLMAP 3.8)

matches with geometric verification?

hello, in clomap, after the feature matching , it will also undergo geometric verification to remove the outlier . I want to know whether it will also undergo geometric verification in deep-image-matching, thank you.

the Error when using 'loftr'

Hi, thank you for your solid work.
When I use 'loftr', will meet 'line 293, in _extract_by_tile, (kpts_full, feat_tile["keypoints"] + np.array(lim[0:2])), ValueError: operands could not be broadcast together with shapes (0,) (2,) '.
Could you give me some advice, thank you.

Running error

Hi,

After done installation by document,
I tried the first step to run help and got this error:
(Running on Win10)

(deep-image-matching) C:\Users\Up2U\Desktop\deep-image-matching\deep-image-matching>python main.py --help
*** Aborted at 1706143103 (unix time) try "date -d @1706143103" if you are using GNU date ***
    @     0x7ff9e6f10ef5 _seh_filter_exe
    @     0x7ff6187a2408 (unknown)
    @     0x7ff9e55de390 __C_specific_handler
    @     0x7ff9e98723af __chkstk
    @     0x7ff9e98214b4 RtlRaiseException
    @     0x7ff9e9870ebe KiUserExceptionDispatcher
    @     0x7ff9b45126de void __cdecl __ExceptionPtrRethrow(void const * __ptr64)
    @     0x7ff95e958f8e public: void __cdecl c10::ivalue::Future::markCompleted(void) __ptr64
    @     0x7ff95ece6b02 struct _object * __ptr64 __cdecl THPGenerator_initDefaultGenerator(struct at::Generator)
    @     0x7ff978e5de65 (unknown)
    @     0x7ff9793bd389 PyInit_pycolmap
    @     0x7ff9d2e11080 (unknown)
    @     0x7ff9d2e126b5 __NLG_Return2
    @     0x7ff9e9871716 RtlCaptureContext2
    @     0x7ff978e60961 (unknown)
    @     0x7ff99c98f0ee _PyArg_ParseTuple_SizeT
    @     0x7ff99c919b3d _PyObject_MakeTpCall
    @     0x7ff99caa2eb6 _PyErr_FormatFromCauseTstate
    @     0x7ff99c92b723 _PyObject_GenericGetAttrWithDict
    @     0x7ff99c92c280 PyObject_GetAttr
    @     0x7ff99c971229 PyObject_GetAttrString
    @     0x7ff978e96cae PyInit_pycolmap
    @     0x7ff978ef3796 PyInit_pycolmap
    @     0x7ff978ec9aad PyInit_pycolmap
    @     0x7ff978e854a3 (unknown)
    @     0x7ff978e91fc8 PyInit_pycolmap
    @     0x7ff978e91ace PyInit_pycolmap
    @     0x7ff99c94c53c PyImport_GetModuleDict
    @     0x7ff99c94c796 PyImport_GetModuleDict
    @     0x7ff99c94c6f1 PyImport_GetModuleDict
    @     0x7ff99c9242e7 PyType_GenericAlloc
    @     0x7ff99c9136e4 PyVectorcall_Call

Thank you.

Remove unmactched features from the h5 file and from COLMAP database after the matching is completed

When using a dataset with a high number of images the features.h5 file and the COLMAP database can become very large as there will be a huge number of features, even though they have no matches (features.h5 can reach also tens of GB).
After the matching is concluded, the features with no matches should be deleted from the h5 file and from the COLMAP database (this can be done just before exporting the features from the h5 to the colmap databse).

Run error with custom images. Could not reconstruct any model!

I am getting the following error when I run on a pair of images. One is a regular rgb image another is the same image in lwir format.

(deep-image-matching) deep-image-matching % python3 main.py
--images ./images
--pipeline superpoint+superglue
PNG file does not have exif data.
2024-04-15 11:58:03 | [INFO ] No exif data available for image img01.jpg (this will probably not affect the matching).
PNG file does not have exif data.
2024-04-15 11:58:03 | [INFO ] No exif data available for image img02.jpg (this will probably not affect the matching).
Loaded SuperPoint model
Loaded SuperGlue model ("outdoor" weights)
2024-04-15 11:58:03 | [INFO ] Running image matching with the following configuration:
2024-04-15 11:58:03 | [INFO ] Image folder: images
2024-04-15 11:58:03 | [INFO ] Output folder: results_superpoint+superglue_matching_lowres_quality_high
2024-04-15 11:58:03 | [INFO ] Number of images: 2
2024-04-15 11:58:03 | [INFO ] Matching strategy: matching_lowres
2024-04-15 11:58:03 | [INFO ] Image quality: HIGH
2024-04-15 11:58:03 | [INFO ] Tile selection: NONE
2024-04-15 11:58:03 | [INFO ] Feature extraction method: superpoint
2024-04-15 11:58:03 | [INFO ] Matching method: superglue
2024-04-15 11:58:03 | [INFO ] Geometric verification: PYDEGENSAC
2024-04-15 11:58:03 | [INFO ] CUDA available: False
2024-04-15 11:58:03 | [INFO ] Low resolution matching, generating pairs ..
Loaded SuperPoint model
2024-04-15 11:58:03 | [INFO ] Extracting features from downsampled images...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:02<00:00, 1.13s/it]
2024-04-15 11:58:06 | [INFO ] Matching downsampled images...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 5.19it/s]
2024-04-15 11:58:06 | [INFO ] Found 0 pairs.
2024-04-15 11:58:06 | [INFO ] Extracting features with superpoint...
2024-04-15 11:58:06 | [INFO ] superpoint configuration:
{'keypoint_threshold': 0.0005,
'max_keypoints': 4096,
'name': 'superpoint',
'nms_radius': 3}
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:02<00:00, 1.47s/it]
2024-04-15 11:58:09 | [INFO ] Features extracted!
2024-04-15 11:58:09 | [INFO ] Matching features with superglue...
2024-04-15 11:58:09 | [INFO ] superglue configuration:
{'match_threshold': 0.3,
'name': 'superglue',
'sinkhorn_iterations': 100,
'weights': 'outdoor'}
2024-04-15 11:58:09 | [INFO ] Matching features...
2024-04-15 11:58:09 | [INFO ]
0it [00:00, ?it/s]
2024-04-15 11:58:09 | [WARNING ] Was not possible to load the first image to initialize cam0
2024-04-15 11:58:09 | [WARNING ] Was not possible to load the first image to initialize cam1
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 44.05it/s]
2024-04-15 11:58:09 | [INFO ] Using pycolmap version 0.6.1
2024-04-15 11:58:09 | [INFO ] Running 3D reconstruction...
I20240415 11:58:09.452909 10708766 misc.cc:198]

Loading database

I20240415 11:58:09.455094 10708766 database_cache.cc:54] Loading cameras...
I20240415 11:58:09.455137 10708766 database_cache.cc:64] 1 in 0.000s
I20240415 11:58:09.455160 10708766 database_cache.cc:72] Loading matches...
I20240415 11:58:09.455184 10708766 database_cache.cc:78] 0 in 0.000s
I20240415 11:58:09.455200 10708766 database_cache.cc:94] Loading images...
I20240415 11:58:09.455260 10708766 database_cache.cc:143] 2 in 0.000s (connected 0)
I20240415 11:58:09.455279 10708766 database_cache.cc:154] Building correspondence graph...
I20240415 11:58:09.455296 10708766 database_cache.cc:190] in 0.000s (ignored 0)
I20240415 11:58:09.455333 10708766 timer.cc:91] Elapsed time: 0.000 [minutes]
W20240415 11:58:09.455351 10708766 incremental_mapper.cc:349] No images with matches found in the database
2024-04-15 11:58:09 | [ERROR ] Could not reconstruct any model!
2024-04-15 11:58:09 | [ERROR ] Pycolmap reconstruction failed
2024-04-15 11:58:09 | [INFO ] [Timer] | [Deep Image Matching] generate_pairs=4.730, extract_features=2.933, matching=0.000, export_to_colmap=0.052, pycolmap reconstruction=0.007, Total execution=7.723

What is the distance unit of the generated file?

I am using the output of deep-image-matching as the input of openMVS. When I get the camera pose and point cloud and try to calculate the distance from the camera to the point for further calculation, I find that I cannot know the unit of the distance. I raised the question in the issue of the openMVS project, and the maintainer told me that openMVS did not change the unit, and the unit was determined during SfM. So I am here to ask a question, how to determine the length unit of deep-image-matching output?

This is the link where I asked a question in openMVS:
cdcseacave/openMVS#1145

Warning loading EXIF

Extend warning description when EXIFs are not correctly imported.In any case, the warning does not affect the correct functioning of the software.

How to define initial camera params

Hi,

First thank you for this awesome project !

I wonder if it is possible to set initial camera params in the cameras.yaml file ?
For example, if I define an OPENCV camera model, can I set initial fx, fy, cx,cy, k1, k2, p1 and p2 params ?

If they are guessed, how are they guessed ?

Do I need to manually update them in the database.db colmap file ? Because the column type is a blob and it might not be easy to do it on command line.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.