Skip to content

Commit

Permalink
Merge branch 'features/colmap_head' into features/ci_test
Browse files Browse the repository at this point in the history
  • Loading branch information
B1ueber2y committed Nov 26, 2024
2 parents 72126af + ae0872f commit 804595e
Show file tree
Hide file tree
Showing 44 changed files with 109 additions and 91 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cfgs/fitnmerge/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions limap/base/bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@ void bind_camera(py::module &m) {
.def(py::init<const std::string &, int, std::pair<int, int>>(),
py::arg("model_name"), py::arg("cam_id") = -1,
py::arg("hw") = std::make_pair<int, int>(-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();
Expand All @@ -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`
Expand Down Expand Up @@ -1052,6 +1056,12 @@ void bind_camera(py::module &m) {
.def(py::init<const std::vector<CameraView> &>(), py::arg("camviews"))
.def(py::init<py::dict>(), py::arg("dict"))
.def(py::init<const ImageCollection &>(), 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();
Expand Down
12 changes: 12 additions & 0 deletions limap/base/camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions limap/base/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Camera : public colmap::Camera {
std::pair<int, int> hw = std::make_pair<int, int>(-1, -1));
Camera(py::dict dict);
Camera(const Camera &cam);
Camera &operator=(const Camera &cam);
Camera(int model, int cam_id = -1,
std::pair<int, int> hw = std::make_pair<int, int>(-1,
-1)); // empty camera
Expand Down
2 changes: 1 addition & 1 deletion limap/base/infinite_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> &values);
InfiniteLine3d GetInfiniteLine() const;
Expand Down
3 changes: 1 addition & 2 deletions limap/base/unit_test.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion limap/evaluation/refline_evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class RefLineEvaluator {
public:
RefLineEvaluator() {}
RefLineEvaluator(const std::vector<Line3d> &ref_lines)
: ref_lines_(ref_lines){};
: ref_lines_(ref_lines) {};

double SumLength() const;
double ComputeRecallRef(const std::vector<Line3d> &lines,
Expand Down
2 changes: 1 addition & 1 deletion limap/features/extractors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# [NOTE] modified from the pixel-perfect-sfm project

import logging
import sys
import time

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion limap/features/models/s2dnet.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import logging
import os
from pathlib import Path
from typing import List

import numpy as np
import torch
import torch.nn as nn
from pycolmap import logging
from torchvision import models

from .base_model import BaseModel
Expand Down
2 changes: 1 addition & 1 deletion limap/line2d/DeepLSD/deeplsd.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion limap/line2d/GlueStick/matcher.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion limap/line2d/HAWPv3/hawp.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import logging
import os

import cv2
import numpy as np
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,
Expand Down
2 changes: 1 addition & 1 deletion limap/line2d/L2D2/extractor.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion limap/line2d/LineTR/line_transformer.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion limap/line2d/SOLD2/misc/train_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


#################
Expand Down
3 changes: 1 addition & 2 deletions limap/line2d/SOLD2/model/model_util.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion limap/line2d/SOLD2/sold2_wrapper.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions limap/line2d/SOLD2/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion limap/line2d/TP_LSD/tp_lsd.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 3 additions & 4 deletions limap/merging/merging.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion limap/optimize/line_refinement/line_refinement.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion limap/point2d/superglue/superglue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion limap/point2d/superpoint/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import collections.abc as collections
import logging
import pprint
from pathlib import Path
from typing import Dict, List, Optional, Union
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion limap/point2d/superpoint/superpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
# --------------------------------------------------------------------*/
# %BANNER_END%

import logging
import os
from pathlib import Path

import torch
from pycolmap import logging
from torch import nn


Expand Down
2 changes: 1 addition & 1 deletion limap/pointsfm/bundler_reader.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
2 changes: 1 addition & 1 deletion limap/pointsfm/colmap_reader.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion limap/pointsfm/colmap_sfm.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import copy
import logging
import os
import shutil
import subprocess
import sys
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
Expand Down
3 changes: 1 addition & 2 deletions limap/pointsfm/functions.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
Loading

0 comments on commit 804595e

Please sign in to comment.