Skip to content

Commit

Permalink
Merge branch 'imports' into egu
Browse files Browse the repository at this point in the history
  • Loading branch information
franioli committed Apr 9, 2024
2 parents d15d2e4 + e60142d commit f4473c8
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 0 deletions.
138 changes: 138 additions & 0 deletions belv_sp+lg.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"from importlib import import_module\n",
"\n",
"import deep_image_matching as dim\n",
"import yaml\n",
"\n",
"logger = dim.setup_logger(\"dim\")\n",
"\n",
"cli_params = {\n",
" \"dir\": \"../assets/example_cyprus\",\n",
" \"pipeline\": \"superpoint+lightglue\",\n",
" \"strategy\": \"matching_lowres\",\n",
" \"quality\": \"high\",\n",
" \"tiling\": \"preselection\",\n",
" \"skip_reconstruction\": False,\n",
" \"force\": True,\n",
" \"camera_options\": \"../config/cameras.yaml\",\n",
" \"openmvg\": None,\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Build configuration\n",
"config = dim.Config(cli_params)\n",
"imgs_dir = config.general[\"image_dir\"]\n",
"output_dir = config.general[\"output_dir\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# - General configuration\n",
"config.general[\"min_inliers_per_pair\"] = 10\n",
"config.general[\"min_inlier_ratio_per_pair\"] = 0.2\n",
"\n",
"# - SuperPoint configuration\n",
"config.extractor[\"max_keypoints\"] = 8000\n",
"\n",
"# - LightGue configuration\n",
"config.matcher[\"filter_threshold\"] = 0.1\n",
"\n",
"# Save configuration to a json file in the output directory\n",
"config.save()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Initialize ImageMatcher class\n",
"matcher = dim.ImageMatcher(config)\n",
"\n",
"# Run image matching\n",
"feature_path, match_path = matcher.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Export in colmap format\n",
"with open(config.general[\"camera_options\"], \"r\") as file:\n",
" camera_options = yaml.safe_load(file)\n",
"database_path = output_dir / \"database.db\"\n",
"dim.io.export_to_colmap(\n",
" img_dir=imgs_dir,\n",
" feature_path=feature_path,\n",
" match_path=match_path,\n",
" database_path=database_path,\n",
" camera_options=camera_options,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from deep_image_matching import graph\n",
"\n",
"graph.view_graph(database_path, output_dir, imgs_dir)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"reconst_opts = {}\n",
"refine_intrinsics = False\n",
"\n",
"# Run reconstruction\n",
"model = dim.reconstruction.pycolmap_reconstruction(\n",
" database_path=output_dir / \"database.db\",\n",
" sfm_dir=output_dir,\n",
" image_dir=imgs_dir,\n",
" options=reconst_opts,\n",
" verbose=config.general[\"verbose\"],\n",
" refine_intrinsics=refine_intrinsics,\n",
")"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
6 changes: 6 additions & 0 deletions src/deep_image_matching/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@
from . import reconstruction
from . import extractors
from . import matchers
from . import visualization

if not NO_PYCOLMAP:
from . import triangulation # the triangulation module strictly requires pycolmap

try:
from . import graph
except ImportError:
logging.warning("pyvis is not available. Unable to visualize view graph.")

# Import functions
from .parser import parse_cli

Expand Down

0 comments on commit f4473c8

Please sign in to comment.