diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 1410019b..767948e4 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -37,8 +37,7 @@ jobs: exit 0 fi set +x -euo pipefail - sudo apt-get update && sudo apt-get install -y clang-format-14 - python -m pip install ruff==0.6.7 + python -m pip install ruff==0.6.7 clang-format==19.1.0 ./scripts/format/clang_format.sh ./scripts/format/python.sh git diff --name-only diff --git a/CMakeLists.txt b/CMakeLists.txt index 23c2b6ce..740c1f8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ option(OPENMP_ENABLED "Whether to enable OpenMP parallelization" ON) option(INTERPOLATION_ENABLED "Whether to enable interpolation-based pixel-perfect optimization" OFF) option(FETCH_POSELIB "Whether to use PoseLib with FetchContent or with self-installed software" ON) option(FETCH_COLMAP "Whether to use COLMAP with FetchContent or with self-installed software" ON) +option(CUDA_ENABLED "Whether to use CUDA (only for the third-party COLMAP)" OFF) include(cmake/FindDependencies.cmake) include(cmake/InitVariables.cmake) diff --git a/cfgs/fitnmerge/default.yaml b/cfgs/fitnmerge/default.yaml index 3867c3db..c7c7a7e3 100644 --- a/cfgs/fitnmerge/default.yaml +++ b/cfgs/fitnmerge/default.yaml @@ -55,7 +55,7 @@ fitting: var2d: -1.0 # depends on the detector ransac_th: 0.75 min_percentage_inliers: 0.9 - n_jobs: 4 + n_jobs: 1 ############################## # merging config diff --git a/limap/base/bindings.cc b/limap/base/bindings.cc index cd0f813a..aaa08488 100644 --- a/limap/base/bindings.cc +++ b/limap/base/bindings.cc @@ -734,6 +734,9 @@ void bind_camera(py::module &m) { .def(py::init>(), py::arg("model_name"), py::arg("cam_id") = -1, py::arg("hw") = std::make_pair(-1, -1)) // empty camera + .def("__copy__", [](const Camera &self) { return Camera(self); }) + .def("__deepcopy__", + [](const Camera &self, const py::dict &) { return Camera(self); }) .def(py::pickle( [](const Camera &input) { // dump return input.as_dict(); @@ -746,6 +749,7 @@ void bind_camera(py::module &m) { .def_readwrite("model", &Camera::model_id, "Camera model.") .def_readwrite("width", &Camera::width, "Width of camera sensor.") .def_readwrite("height", &Camera::height, "Height of camera sensor.") + .def_readwrite("params", &Camera::params, "Camera parameters.") .def("as_dict", &Camera::as_dict, R"( Returns: dict: Python dict representation of this :class:`~limap.base.Camera` @@ -1052,6 +1056,12 @@ void bind_camera(py::module &m) { .def(py::init &>(), py::arg("camviews")) .def(py::init(), py::arg("dict")) .def(py::init(), py::arg("imagecols")) + .def("__copy__", + [](const ImageCollection &self) { return ImageCollection(self); }) + .def("__deepcopy__", + [](const ImageCollection &self, const py::dict &) { + return ImageCollection(self); + }) .def(py::pickle( [](const ImageCollection &input) { // dump return input.as_dict(); diff --git a/limap/base/camera.cc b/limap/base/camera.cc index e579efea..de73f6d3 100644 --- a/limap/base/camera.cc +++ b/limap/base/camera.cc @@ -185,6 +185,18 @@ Camera::Camera(const Camera &cam) { initialized = cam.initialized; } +Camera &Camera::operator=(const Camera &cam) { + if (this != &cam) { + camera_id = cam.camera_id; + model_id = cam.model_id; + params = cam.params; + height = cam.height; + width = cam.width; + initialized = cam.initialized; + } + return *this; +} + bool Camera::operator==(const Camera &cam) { if (camera_id != cam.camera_id) return false; diff --git a/limap/base/camera.h b/limap/base/camera.h index 651af9e6..1cc80260 100644 --- a/limap/base/camera.h +++ b/limap/base/camera.h @@ -56,6 +56,7 @@ class Camera : public colmap::Camera { std::pair hw = std::make_pair(-1, -1)); Camera(py::dict dict); Camera(const Camera &cam); + Camera &operator=(const Camera &cam); Camera(int model, int cam_id = -1, std::pair hw = std::make_pair(-1, -1)); // empty camera diff --git a/limap/base/infinite_line.h b/limap/base/infinite_line.h index a98af4d7..e5eaba0e 100644 --- a/limap/base/infinite_line.h +++ b/limap/base/infinite_line.h @@ -68,7 +68,7 @@ class MinimalInfiniteLine3d { public: MinimalInfiniteLine3d() {} MinimalInfiniteLine3d(const Line3d &line) - : MinimalInfiniteLine3d(InfiniteLine3d(line)){}; + : MinimalInfiniteLine3d(InfiniteLine3d(line)) {}; MinimalInfiniteLine3d(const InfiniteLine3d &inf_line); MinimalInfiniteLine3d(const std::vector &values); InfiniteLine3d GetInfiniteLine() const; diff --git a/limap/base/unit_test.py b/limap/base/unit_test.py index 6d1811be..c93b1716 100644 --- a/limap/base/unit_test.py +++ b/limap/base/unit_test.py @@ -1,7 +1,6 @@ -import logging - import _limap._base as _base import numpy as np +from pycolmap import logging def unit_test_add_noise(imagecols): diff --git a/limap/evaluation/refline_evaluator.h b/limap/evaluation/refline_evaluator.h index 3737f4b0..1fca0978 100644 --- a/limap/evaluation/refline_evaluator.h +++ b/limap/evaluation/refline_evaluator.h @@ -14,7 +14,7 @@ class RefLineEvaluator { public: RefLineEvaluator() {} RefLineEvaluator(const std::vector &ref_lines) - : ref_lines_(ref_lines){}; + : ref_lines_(ref_lines) {}; double SumLength() const; double ComputeRecallRef(const std::vector &lines, diff --git a/limap/features/extractors.py b/limap/features/extractors.py index 6989f07e..7d307911 100644 --- a/limap/features/extractors.py +++ b/limap/features/extractors.py @@ -1,6 +1,5 @@ # [NOTE] modified from the pixel-perfect-sfm project -import logging import sys import time @@ -9,6 +8,7 @@ import torch import torchvision.transforms.functional as tvf from _limap import _features +from pycolmap import logging from torchvision import transforms from .models.s2dnet import S2DNet diff --git a/limap/features/models/s2dnet.py b/limap/features/models/s2dnet.py index b712a838..2788234b 100644 --- a/limap/features/models/s2dnet.py +++ b/limap/features/models/s2dnet.py @@ -1,4 +1,3 @@ -import logging import os from pathlib import Path from typing import List @@ -6,6 +5,7 @@ import numpy as np import torch import torch.nn as nn +from pycolmap import logging from torchvision import models from .base_model import BaseModel diff --git a/limap/line2d/DeepLSD/deeplsd.py b/limap/line2d/DeepLSD/deeplsd.py index 5bd09638..2d111eb0 100644 --- a/limap/line2d/DeepLSD/deeplsd.py +++ b/limap/line2d/DeepLSD/deeplsd.py @@ -1,9 +1,9 @@ -import logging import os import numpy as np import torch from deeplsd.models.deeplsd_inference import DeepLSD +from pycolmap import logging from ..base_detector import ( BaseDetector, diff --git a/limap/line2d/GlueStick/matcher.py b/limap/line2d/GlueStick/matcher.py index eac0e9cf..9492f419 100644 --- a/limap/line2d/GlueStick/matcher.py +++ b/limap/line2d/GlueStick/matcher.py @@ -1,9 +1,9 @@ -import logging import os import numpy as np import torch from gluestick.models.gluestick import GlueStick +from pycolmap import logging from ..base_matcher import ( BaseMatcher, diff --git a/limap/line2d/HAWPv3/hawp.py b/limap/line2d/HAWPv3/hawp.py index ea9aefa5..f5765d80 100644 --- a/limap/line2d/HAWPv3/hawp.py +++ b/limap/line2d/HAWPv3/hawp.py @@ -1,4 +1,3 @@ -import logging import os import cv2 @@ -6,6 +5,7 @@ import torch from hawp.fsl.config import cfg as model_config from hawp.ssl.models import MODELS +from pycolmap import logging from ..base_detector import ( BaseDetector, diff --git a/limap/line2d/L2D2/extractor.py b/limap/line2d/L2D2/extractor.py index 8d122351..fceac1bb 100644 --- a/limap/line2d/L2D2/extractor.py +++ b/limap/line2d/L2D2/extractor.py @@ -1,9 +1,9 @@ -import logging import os import cv2 import numpy as np import torch +from pycolmap import logging import limap.util.io as limapio diff --git a/limap/line2d/LineTR/line_transformer.py b/limap/line2d/LineTR/line_transformer.py index e733b247..0d4dd240 100755 --- a/limap/line2d/LineTR/line_transformer.py +++ b/limap/line2d/LineTR/line_transformer.py @@ -1,9 +1,9 @@ -import logging from copy import deepcopy from pathlib import Path import torch from einops import repeat +from pycolmap import logging from torch import nn from .line_attention import FeedForward, MultiHeadAttention diff --git a/limap/line2d/SOLD2/misc/train_utils.py b/limap/line2d/SOLD2/misc/train_utils.py index 470f0a8e..1a763dac 100644 --- a/limap/line2d/SOLD2/misc/train_utils.py +++ b/limap/line2d/SOLD2/misc/train_utils.py @@ -2,11 +2,11 @@ This file contains some useful functions for train / val. """ -import logging import os import numpy as np import torch +from pycolmap import logging ################# diff --git a/limap/line2d/SOLD2/model/model_util.py b/limap/line2d/SOLD2/model/model_util.py index b638219a..55fd6420 100644 --- a/limap/line2d/SOLD2/model/model_util.py +++ b/limap/line2d/SOLD2/model/model_util.py @@ -1,7 +1,6 @@ -import logging - import torch.nn as nn import torch.nn.init as init +from pycolmap import logging from .nets.backbone import HourglassBackbone, SuperpointBackbone from .nets.descriptor_decoder import SuperpointDescriptor diff --git a/limap/line2d/SOLD2/sold2_wrapper.py b/limap/line2d/SOLD2/sold2_wrapper.py index 648a6733..6088eb35 100644 --- a/limap/line2d/SOLD2/sold2_wrapper.py +++ b/limap/line2d/SOLD2/sold2_wrapper.py @@ -1,10 +1,10 @@ -import logging import os import subprocess import cv2 import numpy as np import torch +from pycolmap import logging from skimage.draw import line from .experiment import load_config diff --git a/limap/line2d/SOLD2/train.py b/limap/line2d/SOLD2/train.py index 522868ef..7585bc8c 100644 --- a/limap/line2d/SOLD2/train.py +++ b/limap/line2d/SOLD2/train.py @@ -2,12 +2,11 @@ This file implements the training process and all the summaries """ -import logging - import cv2 import numpy as np import torch import torch.utils.data.dataloader as torch_loader +from pycolmap import logging from torch.nn.functional import pixel_shuffle, softmax # from model.lr_scheduler import get_lr_scheduler diff --git a/limap/line2d/TP_LSD/tp_lsd.py b/limap/line2d/TP_LSD/tp_lsd.py index 73114199..796810f7 100644 --- a/limap/line2d/TP_LSD/tp_lsd.py +++ b/limap/line2d/TP_LSD/tp_lsd.py @@ -1,9 +1,9 @@ -import logging import os import cv2 import numpy as np import torch +from pycolmap import logging from tp_lsd.modeling.TP_Net import Res320 from tp_lsd.utils.reconstruct import TPS_line from tp_lsd.utils.utils import load_model diff --git a/limap/merging/merging.py b/limap/merging/merging.py index a22fbc24..65286d8d 100644 --- a/limap/merging/merging.py +++ b/limap/merging/merging.py @@ -1,7 +1,6 @@ -import logging - from _limap import _base from _limap import _merging as _mrg +from pycolmap import logging def merging(linker, all_2d_segs, imagecols, seg3d_list, neighbors, var2d=5.0): @@ -37,8 +36,8 @@ def remerge(linker3d, linetracks, num_outliers=2): break num_tracks = num_tracks_new logging.info( - f"[LOG] tracks after iterative remerging: \ - {len(new_linetracks)} / {len(linetracks)}" + f"[LOG] tracks after iterative remerging:" + f" {len(new_linetracks)} / {len(linetracks)}" ) return new_linetracks diff --git a/limap/optimize/line_refinement/line_refinement.py b/limap/optimize/line_refinement/line_refinement.py index 9b546741..9c7a854b 100644 --- a/limap/optimize/line_refinement/line_refinement.py +++ b/limap/optimize/line_refinement/line_refinement.py @@ -1,7 +1,7 @@ -import logging import os import numpy as np +from pycolmap import logging from tqdm import tqdm import limap.base as base diff --git a/limap/point2d/superglue/superglue.py b/limap/point2d/superglue/superglue.py index 4457bdb4..f4e5942f 100644 --- a/limap/point2d/superglue/superglue.py +++ b/limap/point2d/superglue/superglue.py @@ -40,13 +40,13 @@ # --------------------------------------------------------------------*/ # %BANNER_END% -import logging import os from copy import deepcopy from pathlib import Path from typing import List, Tuple import torch +from pycolmap import logging from torch import nn diff --git a/limap/point2d/superpoint/main.py b/limap/point2d/superpoint/main.py index e4e6fcb5..8735f992 100644 --- a/limap/point2d/superpoint/main.py +++ b/limap/point2d/superpoint/main.py @@ -1,5 +1,4 @@ import collections.abc as collections -import logging import pprint from pathlib import Path from typing import Dict, List, Optional, Union @@ -9,6 +8,7 @@ import torch from hloc import extract_features from hloc.utils.io import list_h5_names +from pycolmap import logging from tqdm import tqdm from .superpoint import SuperPoint diff --git a/limap/point2d/superpoint/superpoint.py b/limap/point2d/superpoint/superpoint.py index c164ec0f..833a60e0 100644 --- a/limap/point2d/superpoint/superpoint.py +++ b/limap/point2d/superpoint/superpoint.py @@ -40,11 +40,11 @@ # --------------------------------------------------------------------*/ # %BANNER_END% -import logging import os from pathlib import Path import torch +from pycolmap import logging from torch import nn diff --git a/limap/pointsfm/bundler_reader.py b/limap/pointsfm/bundler_reader.py index 9e91676d..f1253268 100644 --- a/limap/pointsfm/bundler_reader.py +++ b/limap/pointsfm/bundler_reader.py @@ -1,9 +1,9 @@ -import logging import os import imagesize import numpy as np from _limap import _base, _pointsfm +from pycolmap import logging from tqdm import tqdm diff --git a/limap/pointsfm/colmap_reader.py b/limap/pointsfm/colmap_reader.py index 60aa3355..9f896c4d 100644 --- a/limap/pointsfm/colmap_reader.py +++ b/limap/pointsfm/colmap_reader.py @@ -1,8 +1,8 @@ -import logging import os import sys from _limap import _base +from pycolmap import logging sys.path.append(os.path.dirname(os.path.abspath(__file__))) from hloc.utils.read_write_model import ( diff --git a/limap/pointsfm/colmap_sfm.py b/limap/pointsfm/colmap_sfm.py index 781ebe96..01be7922 100644 --- a/limap/pointsfm/colmap_sfm.py +++ b/limap/pointsfm/colmap_sfm.py @@ -1,5 +1,4 @@ import copy -import logging import os import shutil import subprocess @@ -7,6 +6,7 @@ from pathlib import Path import cv2 +from pycolmap import logging sys.path.append(os.path.dirname(os.path.abspath(__file__))) import hloc.utils.database as database diff --git a/limap/pointsfm/functions.py b/limap/pointsfm/functions.py index d504888e..0561c305 100644 --- a/limap/pointsfm/functions.py +++ b/limap/pointsfm/functions.py @@ -1,6 +1,5 @@ -import logging - from _limap import _pointsfm +from pycolmap import logging def filter_by_cam_id(cam_id, prev_imagecols, prev_neighbors): diff --git a/limap/runners/functions.py b/limap/runners/functions.py index 360cacbf..d5795ab0 100644 --- a/limap/runners/functions.py +++ b/limap/runners/functions.py @@ -1,6 +1,6 @@ -import logging import os +from pycolmap import logging from tqdm import tqdm import limap.line2d @@ -60,8 +60,8 @@ def undistort_images( unload_ids = imagecols.get_img_ids() if skip_exists: logging.info( - f"[LOG] Loading undistorted images \ - (n_images = {imagecols.NumImages()})..." + f"[LOG] Loading undistorted images " + f"(n_images = {imagecols.NumImages()})..." ) fname_in = os.path.join(output_dir, fname) if os.path.isfile(fname_in): @@ -213,8 +213,8 @@ def compute_2d_segs(cfg, imagecols, compute_descinfo=True): weight_path = cfg.get("weight_path", None) if "extractor" in cfg["line2d"]: logging.info( - "[LOG] Start 2D line detection and description \ - (detector = {}, extractor = {}, n_images = {})...".format( + "[LOG] Start 2D line detection and description " + "(detector = {}, extractor = {}, n_images = {})...".format( cfg["line2d"]["detector"]["method"], cfg["line2d"]["extractor"]["method"], imagecols.NumImages(), @@ -222,8 +222,8 @@ def compute_2d_segs(cfg, imagecols, compute_descinfo=True): ) else: logging.info( - "[LOG] Start 2D line detection and description \ - (detector = {}, n_images = {})...".format( + "[LOG] Start 2D line detection and description " + "(detector = {}, n_images = {})...".format( cfg["line2d"]["detector"]["method"], imagecols.NumImages() ) ) @@ -306,8 +306,8 @@ def compute_matches(cfg, descinfo_folder, image_ids, neighbors): """ weight_path = cfg.get("weight_path", None) logging.info( - "[LOG] Start matching 2D lines... (extractor = {}, matcher = {}, \ - n_images = {}, n_neighbors = {})".format( + "[LOG] Start matching 2D lines... (extractor = {}, matcher = {}," + "n_images = {}, n_neighbors = {})".format( cfg["line2d"]["extractor"]["method"], cfg["line2d"]["matcher"]["method"], len(image_ids), @@ -359,8 +359,8 @@ def compute_exhaustive_matches(cfg, descinfo_folder, image_ids): matches_folder (str): path to store the computed matches """ logging.info( - "[LOG] Start exhausive matching 2D lines... \ - (extractor = {}, matcher = {}, n_images = {})".format( + "[LOG] Start exhausive matching 2D lines..." + "(extractor = {}, matcher = {}, n_images = {})".format( cfg["line2d"]["extractor"]["method"], cfg["line2d"]["matcher"]["method"], len(image_ids), diff --git a/limap/runners/functions_structures.py b/limap/runners/functions_structures.py index a046e417..669dbeb8 100644 --- a/limap/runners/functions_structures.py +++ b/limap/runners/functions_structures.py @@ -1,7 +1,7 @@ -import logging import os import numpy as np +from pycolmap import logging from tqdm import tqdm import limap.pointsfm as pointsfm diff --git a/limap/runners/hybrid_localization.py b/limap/runners/hybrid_localization.py index 02c0baec..3fd617b5 100644 --- a/limap/runners/hybrid_localization.py +++ b/limap/runners/hybrid_localization.py @@ -1,9 +1,9 @@ -import logging import os from collections import defaultdict import numpy as np from hloc.utils.io import get_keypoints, get_matches +from pycolmap import logging from tqdm import tqdm import limap.base as base diff --git a/limap/runners/line_fitnmerge.py b/limap/runners/line_fitnmerge.py index df0b6b3d..1905f6e4 100644 --- a/limap/runners/line_fitnmerge.py +++ b/limap/runners/line_fitnmerge.py @@ -1,8 +1,8 @@ -import logging import os import joblib import numpy as np +from pycolmap import logging from tqdm import tqdm import limap.base as base diff --git a/limap/runners/line_triangulation.py b/limap/runners/line_triangulation.py index d865120a..e1a0349d 100644 --- a/limap/runners/line_triangulation.py +++ b/limap/runners/line_triangulation.py @@ -1,6 +1,6 @@ -import logging import os +from pycolmap import logging from tqdm import tqdm import limap.base as base diff --git a/limap/util/evaluation.py b/limap/util/evaluation.py index 9bbe22e0..5687a136 100644 --- a/limap/util/evaluation.py +++ b/limap/util/evaluation.py @@ -1,7 +1,6 @@ -import logging - import cv2 import numpy as np +from pycolmap import logging import limap.base as base diff --git a/limap/util/io.py b/limap/util/io.py index 75fad647..1dad7d50 100644 --- a/limap/util/io.py +++ b/limap/util/io.py @@ -1,8 +1,8 @@ -import logging import os import shutil import numpy as np +from pycolmap import logging from tqdm import tqdm import limap.base as base diff --git a/limap/visualize/trackvis/base.py b/limap/visualize/trackvis/base.py index 7999c75b..e7fd644f 100644 --- a/limap/visualize/trackvis/base.py +++ b/limap/visualize/trackvis/base.py @@ -1,6 +1,5 @@ -import logging - import numpy as np +from pycolmap import logging from ..vis_utils import test_line_inside_ranges @@ -26,14 +25,14 @@ def report(self): def report_stats(self): counts = np.array(self.counts) logging.info( - f"[Track Report] (N2, N4, N6, N8, N10, N20, N50) = \ - ({counts[counts >= 2].shape[0]}, \ - {counts[counts >= 4].shape[0]}, \ - {counts[counts >= 6].shape[0]}, \ - {counts[counts >= 8].shape[0]}, \ - {counts[counts >= 10].shape[0]}, \ - {counts[counts >= 20].shape[0]}, \ - {counts[counts >= 50].shape[0]})" + f"[Track Report] (N2, N4, N6, N8, N10, N20, N50) =" + f" ({counts[counts >= 2].shape[0]}," + f" {counts[counts >= 4].shape[0]}," + f" {counts[counts >= 6].shape[0]}," + f" {counts[counts >= 8].shape[0]}," + f" {counts[counts >= 10].shape[0]}," + f" {counts[counts >= 20].shape[0]}," + f" {counts[counts >= 50].shape[0]})" ) def report_avg_supports(self, n_visible_views=4): @@ -42,12 +41,12 @@ def report_avg_supports(self, n_visible_views=4): arr = counts[counts >= n_visible_views] arr_lines = counts_lines[counts >= n_visible_views] logging.info( - f"average supporting images (>= {n_visible_views}): \ - {arr.sum()} / {arr.shape[0]} = {arr.mean():.2f}" + f"average supporting images (>= {n_visible_views}):" + f" {arr.sum()} / {arr.shape[0]} = {arr.mean():.2f}" ) logging.info( - f"average supporting lines (>= {n_visible_views}): \ - {arr_lines.sum()} / {arr_lines.shape[0]} = {arr_lines.mean():.2f}" + f"average supporting lines (>= {n_visible_views}): " + f"{arr_lines.sum()} / {arr_lines.shape[0]} = {arr_lines.mean():.2f}" ) def get_counts_np(self): diff --git a/limap/visualize/vis_utils.py b/limap/visualize/vis_utils.py index c07e5a63..142a495a 100644 --- a/limap/visualize/vis_utils.py +++ b/limap/visualize/vis_utils.py @@ -1,11 +1,11 @@ import copy -import logging import os import cv2 import matplotlib.pyplot as plt import numpy as np import seaborn as sns +from pycolmap import logging def random_color(): diff --git a/requirements.txt b/requirements.txt index 8c96c2a7..c038eeac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,8 +21,9 @@ imagesize einops ninja yacs -python-json-logger +pycolmap ruff==0.6.7 +clang-format==19.1.0 ./third-party/pytlsd ./third-party/Hierarchical-Localization diff --git a/scripts/eval_hypersim.py b/scripts/eval_hypersim.py index b584e753..d91c0ae5 100644 --- a/scripts/eval_hypersim.py +++ b/scripts/eval_hypersim.py @@ -4,6 +4,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import matplotlib.pyplot as plt import numpy as np +from pycolmap import logging from tqdm import tqdm import limap.evaluation as limap_eval @@ -58,11 +59,11 @@ def report_error_to_GT(evaluator, lines, vis_err_th=None): list_recall.append(length_recall) precision = 100 * (ratios > 0).astype(int).sum() / ratios.shape[0] list_precision.append(precision) - print("R: recall, P: precision") + logging.info("R: recall, P: precision") for idx, threshold in enumerate(thresholds): - print( - f"R / P at {int(threshold * 1000)}mm: \ - {list_recall[idx]:.2f} / {list_precision[idx]:.2f}" + logging.info( + f"R / P at {int(threshold * 1000)}mm: " + f"{list_recall[idx]:.2f} / {list_precision[idx]:.2f}" ) return evaluator @@ -75,7 +76,7 @@ def read_ply(fname): y = np.asarray(plydata.elements[0].data["y"]) z = np.asarray(plydata.elements[0].data["z"]) points = np.stack([x, y, z], axis=1) - print(f"number of points: {points.shape[0]}") + logging.info(f"number of points: {points.shape[0]}") return points @@ -282,9 +283,9 @@ def main(): sup_line_counts = np.array( [track.count_lines() for track in linetracks] ) - print( - f"supporting images / lines: ({sup_image_counts.mean():.2f} \ - / {sup_line_counts.mean():.2f})" + logging.info( + f"supporting images / lines: ({sup_image_counts.mean():.2f} " + f"/ {sup_line_counts.mean():.2f})" ) diff --git a/scripts/eval_tnt.py b/scripts/eval_tnt.py index b7297a1f..5cb7678f 100644 --- a/scripts/eval_tnt.py +++ b/scripts/eval_tnt.py @@ -4,6 +4,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import matplotlib.pyplot as plt import numpy as np +from pycolmap import logging from tqdm import tqdm import limap.base as base @@ -31,9 +32,9 @@ def report_error_to_GT(evaluator, lines): precision = 100 * (ratios > 0).astype(int).sum() / ratios.shape[0] list_precision.append(precision) for idx, threshold in enumerate(thresholds): - print( - f"R / P at {int(threshold * 1000)}mm: \ - {list_recall[idx]:.2f} / {list_precision[idx]:.2f}" + logging.info( + f"R / P at {int(threshold * 1000)}mm: " + f"{list_recall[idx]:.2f} / {list_precision[idx]:.2f}" ) return evaluator @@ -47,13 +48,13 @@ def report_pc_recall_for_GT(evaluator, lines): # point_dists = evaluator.ComputeDistsforEachPoint_KDTree(lines) point_dists = np.array(point_dists) n_points = point_dists.shape[0] - print("Compute point recall metrics.") + logging.info("Compute point recall metrics.") for threshold in thresholds.tolist(): num_inliers = (point_dists < threshold).sum() point_recall = 100 * num_inliers / n_points - print( - f"{int(threshold * 1000):.0f}mm, inliers = {num_inliers}, \ - point recall = {point_recall:.2f}" + logging.info( + f"{int(threshold * 1000):.0f}mm, inliers = {num_inliers}, " + f"point recall = {point_recall:.2f}" ) return evaluator @@ -66,7 +67,7 @@ def read_ply(fname): y = np.asarray(plydata.elements[0].data["y"]) z = np.asarray(plydata.elements[0].data["z"]) points = np.stack([x, y, z], axis=1) - print(f"number of points: {points.shape[0]}") + logging.info(f"number of points: {points.shape[0]}") return points @@ -118,7 +119,7 @@ def eval_tnt(cfg, lines, ref_lines=None): for line in lines if limapvis.test_line_inside_ranges(line, ranges) ] - print(f"Filtering by range: {len(lines)} / {n_lines}") + logging.info(f"Filtering by range: {len(lines)} / {n_lines}") evaluator = report_error_to_point_cloud( points, lines, kdtree_dir=cfg["kdtree_dir"] ) @@ -215,7 +216,6 @@ def parse_config(): cfg["noeval"] = args.noeval cfg["transform_txt"] = args.transform_txt cfg["use_ranges"] = args.use_ranges - # print(cfg) return cfg @@ -278,9 +278,9 @@ def main(): sup_line_counts = np.array( [track.count_lines() for track in linetracks] ) - print( - f"supporting images / lines: ({sup_image_counts.mean():.2f} \ - / {sup_line_counts.mean():.2f})" + logging.info( + f"supporting images / lines: ({sup_image_counts.mean():.2f} " + f"/ {sup_line_counts.mean():.2f})" ) diff --git a/scripts/format/clang_format.sh b/scripts/format/clang_format.sh index a70a0c8a..d978b650 100755 --- a/scripts/format/clang_format.sh +++ b/scripts/format/clang_format.sh @@ -24,7 +24,7 @@ echo "Found clang-format: $(which ${clang_format})" # Check version version_string=$($clang_format --version | sed -E 's/^.*(\d+\.\d+\.\d+-.*).*$/\1/') -expected_version_string='14.0.0' +expected_version_string='19.1.0' if [[ "$version_string" =~ "$expected_version_string" ]]; then echo "clang-format version '$version_string' matches '$expected_version_string'" else diff --git a/third-party/DeepLSD b/third-party/DeepLSD index 59006b26..17c76459 160000 --- a/third-party/DeepLSD +++ b/third-party/DeepLSD @@ -1 +1 @@ -Subproject commit 59006b264d05e97856556d3f16ded45bd4dbc286 +Subproject commit 17c764595b17f619e6f78c5f9fc18f1f970ea579