Open3D (C++ API)  0.16.0
SLACOptimizer.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// The MIT License (MIT)
5//
6// Copyright (c) 2018-2021 www.open3d.org
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to deal
10// in the Software without restriction, including without limitation the rights
11// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12// copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25// ----------------------------------------------------------------------------
26
27#pragma once
28
29#include <string>
30#include <vector>
31
35
36namespace open3d {
37namespace t {
38namespace pipelines {
39namespace slac {
40
42
46
50
53
56
59
62
64 std::string slac_folder_ = "";
65 std::string GetSubfolderName() const {
66 if (voxel_size_ < 0) {
67 return fmt::format("{}/original", slac_folder_);
68 }
69 return fmt::format("{}/{:.3f}", slac_folder_, voxel_size_);
70 }
71
85 SLACOptimizerParams(const int max_iterations = 5,
86 const float voxel_size = 0.05,
87 const float distance_threshold = 0.07,
88 const float fitness_threshold = 0.3,
89 const float regularizer_weight = 1,
90 const core::Device device = core::Device("CPU:0"),
91 const std::string slac_folder = "") {
92 if (fitness_threshold < 0) {
93 utility::LogError("fitness threshold must be positive.");
94 }
95 if (distance_threshold < 0) {
96 utility::LogError("distance threshold must be positive.");
97 }
98
99 max_iterations_ = max_iterations;
100 voxel_size_ = voxel_size;
101 distance_threshold_ = distance_threshold;
102 fitness_threshold_ = fitness_threshold;
103 regularizer_weight_ = regularizer_weight;
104 device_ = device;
105 slac_folder_ = slac_folder;
106 }
107};
108
111 bool debug_ = false;
112
116
122 SLACDebugOption(const bool debug = false,
123 const int debug_start_node_idx = 0) {
124 if (debug_start_node_idx < 0) {
125 utility::LogError("debug_start_node_idx must be positive integer.");
126 }
127
128 debug_ = debug;
129 debug_start_node_idx_ = debug_start_node_idx;
130 }
131
136 SLACDebugOption(const int debug_start_node_idx) {
137 if (debug_start_node_idx < 0) {
138 utility::LogError("debug_start_node_idx must be positive integer.");
139 }
140
141 debug_ = true;
142 debug_start_node_idx_ = debug_start_node_idx;
143 }
144};
145
156 const std::vector<std::string>& fnames_processed,
157 const PoseGraph& fragment_pose_graph,
158 const SLACOptimizerParams& params = SLACOptimizerParams(),
159 const SLACDebugOption& debug_option = SLACDebugOption());
160
171std::pair<PoseGraph, ControlGrid> RunSLACOptimizerForFragments(
172 const std::vector<std::string>& fragment_filenames,
173 const PoseGraph& fragment_pose_graph,
174 const SLACOptimizerParams& params = SLACOptimizerParams(),
175 const SLACDebugOption& debug_option = SLACDebugOption());
176
186 const std::vector<std::string>& fragment_filenames,
187 const PoseGraph& fragment_pose_graph,
188 const SLACOptimizerParams& params = SLACOptimizerParams(),
189 const SLACDebugOption& debug_option = SLACDebugOption());
190
191} // namespace slac
192} // namespace pipelines
193} // namespace t
194} // namespace open3d
filament::Texture::InternalFormat format
Definition: FilamentResourceManager.cpp:214
#define LogError(...)
Definition: Logging.h:67
Definition: Device.h:37
Data structure defining the pose graph.
Definition: PoseGraph.h:115
PoseGraph RunRigidOptimizerForFragments(const std::vector< std::string > &fnames, const PoseGraph &pose_graph, const SLACOptimizerParams &params, const SLACDebugOption &debug_option)
Extended ICP to simultaneously align multiple point clouds with dense pairwise point-to-plane distanc...
Definition: SLACOptimizer.cpp:388
open3d::pipelines::registration::PoseGraph PoseGraph
Definition: SLACOptimizer.h:41
void SaveCorrespondencesForPointClouds(const std::vector< std::string > &fnames_processed, const PoseGraph &pose_graph, const SLACOptimizerParams &params, const SLACDebugOption &debug_option)
Read pose graph containing loop closures and odometry to compute putative correspondences between pai...
Definition: SLACOptimizer.cpp:227
std::pair< PoseGraph, ControlGrid > RunSLACOptimizerForFragments(const std::vector< std::string > &fnames, const PoseGraph &pose_graph, const SLACOptimizerParams &params, const SLACDebugOption &debug_option)
Simultaneous Localization and Calibration: Self-Calibration of Consumer Depth Cameras,...
Definition: SLACOptimizer.cpp:316
Definition: PinholeCameraIntrinsic.cpp:35
Definition: SLACOptimizer.h:109
bool debug_
Enable debug.
Definition: SLACOptimizer.h:111
SLACDebugOption(const bool debug=false, const int debug_start_node_idx=0)
Definition: SLACOptimizer.h:122
int debug_start_node_idx_
Definition: SLACOptimizer.h:115
SLACDebugOption(const int debug_start_node_idx)
Definition: SLACOptimizer.h:136
float distance_threshold_
Distance threshold to filter inconsistent correspondences.
Definition: SLACOptimizer.h:52
std::string slac_folder_
Relative directory to store SLAC results in the dataset folder.
Definition: SLACOptimizer.h:64
SLACOptimizerParams(const int max_iterations=5, const float voxel_size=0.05, const float distance_threshold=0.07, const float fitness_threshold=0.3, const float regularizer_weight=1, const core::Device device=core::Device("CPU:0"), const std::string slac_folder="")
Definition: SLACOptimizer.h:85
float voxel_size_
Definition: SLACOptimizer.h:49
float regularizer_weight_
Weight of the regularizer.
Definition: SLACOptimizer.h:58
std::string GetSubfolderName() const
Definition: SLACOptimizer.h:65
float fitness_threshold_
Fitness threshold to filter inconsistent pairs.
Definition: SLACOptimizer.h:55
core::Device device_
Device to use.
Definition: SLACOptimizer.h:61
int max_iterations_
Number of iterations.
Definition: SLACOptimizer.h:45