Skip to content

Commit df757f4

Browse files
authored
Merge pull request #36 from meyerls/refactor
This merge makes several structural changes. The localizer is no longer its own class, but a series of stateless functions. I've removed manual registration and created a base class for projects which other structure from motion software can extend upon for use in this module.
2 parents 65be295 + d59cdae commit df757f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2446
-4547
lines changed

.DS_Store

-2 KB
Binary file not shown.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
aruco_estimator/data/
33
data/
44
__pycache__/
5+
*.zip
6+
door/
7+
dumpy/
58

69
# Byte-compiled / optimized / DLL files
710
__pycache__/git s

.old/currie/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This doesnt use the module code and wont be maintained as part of it. By directly calling a colmap process and performing reconstruction, it breaks the contract of the module, which is to perform registration tasks on arbitrary reconstruction projects. I've left it accesible as I didnt call it out during your PR.
2+
3+
I have placed some of my own code in here, which I developed for my project on my fork, but breaks the contract of the module.
4+
5+
There are colmap dependencies throughout the project which I'll be isolating before the next PyPi release.
File renamed without changes.
File renamed without changes.

example.py renamed to .old/currie/example.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import logging
22
from pathlib import Path
33

4+
from colmap_wrapper.colmap import COLMAP
5+
46
# This patches pycolmap to fix a bug in colmap_wrapper
57
import aruco_estimator.patch_colmap # noqa: F401
6-
from aruco_estimator.localizers import ArucoLocalizer
8+
from aruco_estimator import ArucoLocalizer
79
from aruco_estimator.tools.colmap_recon import generate_colmap
810
from aruco_estimator.tools.downloader import DOOR_DATASET, Dataset
911
from aruco_estimator.visualization import ArucoVisualization
10-
from colmap_wrapper.colmap import COLMAP
1112

1213
DO_COLMAP_STEP = True
1314

aruco_estimator/tools/reverse_project.py renamed to .old/currie/reverse_project.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import os
2+
23
import cv2
34
import numpy as np
45

5-
from aruco_estimator.colmap.read_write_model import read_model
6+
from aruco_estimator.sfm.colmap import read_model
67

78

89
def read_key_positions(filepath):

aruco_estimator/tools/registration.py renamed to .old/registration.py

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,58 @@
1212
import open3d as o3d
1313
from colmap_wrapper.colmap import COLMAP
1414

15-
from aruco_estimator.localizers import ArucoLocalizer
15+
from aruco_estimator import ArucoLocalizer
1616
from aruco_estimator.utils import (
1717
align_point_set,
18-
manual_registration,
1918
plot_aligned_pointset,
2019
)
2120
from aruco_estimator.visualization import ArucoVisualization
2221

2322

23+
def manual_registration(pcd_1, pcd_2):
24+
"""
25+
Source: http://www.open3d.org/docs/latest/tutorial/Advanced/interactive_visualization.html
26+
27+
@param pcd_1:
28+
@param pcd_2:
29+
@return:
30+
"""
31+
32+
def pick_points(pcd):
33+
logging.info("")
34+
logging.info(
35+
"1) Please pick at least three correspondences using [shift + left click]"
36+
)
37+
logging.info(" Press [shift + right click] to undo point picking")
38+
logging.info("2) After picking points, press 'Q' to close the window")
39+
viewer = o3d.visualization.VisualizerWithEditing()
40+
viewer.create_window(window_name='Picker')
41+
opt = viewer.get_render_option()
42+
# opt.show_coordinate_frame = True
43+
opt.point_size = 2.5
44+
viewer.add_geometry(pcd)
45+
viewer.run() # user picks points
46+
viewer.destroy_window()
47+
logging.info("")
48+
return viewer.get_picked_points()
49+
50+
def draw_registration_result(source, target, transformation):
51+
source_temp = copy.deepcopy(source)
52+
target_temp = copy.deepcopy(target)
53+
source_temp.paint_uniform_color([1, 0.706, 0])
54+
target_temp.paint_uniform_color([0, 0.651, 0.929])
55+
source_temp.transform(transformation)
56+
o3d.visualization.draw_geometries([source_temp, target_temp])
57+
58+
# pick points from two point clouds and builds correspondences
59+
picked_id_source = pick_points(pcd_1)
60+
picked_id_target = pick_points(pcd_2)
61+
62+
picked_points_1 = pcd_1.select_by_index(picked_id_source)
63+
picked_points_2 = pcd_1.select_by_index(picked_id_target)
64+
65+
return np.asarray(picked_points_1.points), np.asarray(picked_points_2.points)
66+
2467
class ArucoRegistration(object):
2568
def __init__(self, project_path_a: str, project_path_b: str, dense_pc: str = 'fused.ply'):
2669
# Name of both subprojects

aruco_estimator/visualization/visualization_scale_factor_estimator.py renamed to .old/visualization_scale_factor_estimator.py

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
See LICENSE file for more information.
77
"""
88

9-
import logging
109

1110
import numpy as np
1211
import open3d as o3d
@@ -16,8 +15,56 @@
1615
generate_line_set,
1716
)
1817

19-
from ..localizers import ArucoLocalizer
20-
from .visualization import ray_cast_aruco_corners_visualization
18+
from . import ArucoLocalizer
19+
20+
"""
21+
Copyright (c) 2022 Lukas Meyer
22+
Licensed under the MIT License.
23+
See LICENSE file for more information.
24+
"""
25+
26+
# Built-in/Generic Imports
27+
28+
# Libs
29+
30+
31+
def ray_cast_aruco_corners_visualization(p_i: np.ndarray, n_i: np.ndarray, corners3d: np.ndarray) \
32+
-> o3d.pybind.geometry.LineSet:
33+
'''
34+
35+
@param p_i:
36+
@param n_i:
37+
@param corners3d:
38+
@return:
39+
'''
40+
41+
p1_0, p1_1, p1_2, p1_3 = corners3d[0], corners3d[1], corners3d[2], corners3d[3]
42+
t_0 = np.linalg.norm((p1_0 - p_i))
43+
t_1 = np.linalg.norm((p1_1 - p_i))
44+
t_2 = np.linalg.norm((p1_2 - p_i))
45+
t_3 = np.linalg.norm((p1_3 - p_i))
46+
47+
points_camera_plane = [
48+
p_i,
49+
p_i + n_i[0] * t_0, # p1_0,
50+
p_i + n_i[1] * t_1, # p1_1,
51+
p_i + n_i[2] * t_2, # p1_2,
52+
p_i + n_i[3] * t_3, # p1_3,
53+
]
54+
55+
lines = [
56+
[0, 1],
57+
[0, 2],
58+
[0, 3],
59+
[0, 4],
60+
]
61+
aruco_line_set = generate_line_set(points=points_camera_plane,
62+
lines=lines,
63+
color=[1, 0, 0])
64+
65+
return aruco_line_set
66+
67+
2168

2269

2370
class ScaleFactorExtimatorVisualization():

0 commit comments

Comments
 (0)