23 static const std::unordered_map<std::string, std::string>
26 "List of filenames (str) for pre-processed pointcloud "
28 {
"fragment_filenames",
29 "List of filenames (str) for pointcloud fragments."},
30 {
"fragment_pose_graph",
"PoseGraph for pointcloud fragments"},
32 "slac_optimizer_params Parameters to tune in optimization."},
33 {
"debug_option",
"debug options."}};
36 py::module m_slac = m.def_submodule(
38 "Tensor-based Simultaneous Localisation and Calibration pipeline.");
39 py::class_<SLACOptimizerParams> slac_optimizer_params(
40 m_slac,
"slac_optimizer_params",
41 "SLAC parameters to tune in optimization.");
42 py::detail::bind_copy_functions<SLACOptimizerParams>(slac_optimizer_params);
44 .def(py::init<
const int,
const float,
const float,
const float,
46 "max_iterations"_a = 5,
"voxel_size"_a = 0.05,
47 "distance_threshold"_a = 0.07,
"fitness_threshold"_a = 0.3,
48 "regularizer_weight"_a = 1,
"device"_a =
core::Device(
"CPU:0"),
50 .def_readwrite(
"max_iterations",
52 "Number of iterations.")
54 "Voxel size to downsample input point cloud.")
55 .def_readwrite(
"distance_threshold",
57 " Distance threshold to filter inconsistent "
59 .def_readwrite(
"fitness_threshold",
61 "Fitness threshold to filter inconsistent pairs.")
62 .def_readwrite(
"regularizer_weight",
64 "Weight of the regularizer.")
68 "Relative directory to store SLAC results in the "
73 return slac_optimizer_params.GetSubfolderName();
75 "Relative directory to store SLAC results in the dataset "
79 "SLACOptimizerParams(max_iterations={:d}, "
80 "voxel_size={:e}, distance_threshold={:e}, "
81 "fitness_threshold={:e}, regularizer_weight={:e}, "
82 "device=cloudViewer.core.Device(\"{}\"), "
83 "slac_folder=\"{}\")",
90 py::class_<SLACDebugOption> slac_debug_option(m_slac,
"slac_debug_option",
91 "SLAC debug options.");
92 py::detail::bind_copy_functions<SLACDebugOption>(slac_debug_option);
94 .def(py::init<const bool, const int>(),
"debug"_a =
false,
95 "debug_start_node_idx"_a = 0)
96 .def(py::init<const int>(),
"debug_start_node_idx"_a)
98 .def_readwrite(
"debug_start_node_idx",
100 "The node id to start debugging with. Smaller nodes "
101 "will be skipped for visualization.")
104 "SLACDebugOption(debug={}, "
105 "debug_start_node_idx={:d})",
106 debug_option.
debug_ ?
"True" :
"False",
109 py::class_<ControlGrid> control_grid(
110 m_slac,
"control_grid",
111 " ControlGrid is a spatially hashed voxel grid used for non-rigid "
112 "point cloud registration and TSDF integration. Each grid stores a "
113 "map from the initial grid location to the deformed location. You "
114 "can imagine a control grid as a jelly that is warped upon "
115 "perturbation with its overall shape preserved. "
117 "https://github.com/qianyizh/ElasticReconstruction/blob/master/"
118 "FragmentOptimizer/OptApp.cpp "
119 "http://vladlen.info/papers/elastic-fragments.pdf. ");
120 py::detail::bind_copy_functions<ControlGrid>(control_grid);
121 control_grid.def(py::init<>())
122 .def(py::init<float, int64_t, const core::Device>(),
"grid_size"_a,
123 "grid_count"_a = 1000,
"device"_a =
core::Device(
"CPU:0"))
126 "grid_size"_a,
"keys"_a,
"values"_a,
131 control_grid.Touch(pcd);
133 "Allocate control grids in the shared camera space.",
136 "Force rehashing, so that all entries are remapped to [0, "
137 "size) and form a contiguous index map.")
139 "Get the neighbor indices per grid to construct the "
141 "Returns a 6-way neighbor grid map for all the active "
142 "entries of shape (N, ). "
143 "\n - buf_indices Active indices in the buffer of shape (N, ) "
144 "\n - buf_indices_nb Neighbor indices (including "
146 "entries) for the active entries of shape (N, 6). "
147 "\n - masks_nb Corresponding neighbor masks of shape (N, "
153 return control_grid.Parameterize(pcd);
155 "Parameterize an input point cloud by embedding each point "
157 "with 8 corners via indexing and interpolation. "
158 "Returns: A PointCloud with parameterization attributes: "
159 "\n- neighbors: Index of 8 neighbor control grid points of "
160 "shape (8, ) in Int64. "
161 "\n- ratios: Interpolation ratios of 8 neighbor control "
162 "grid points of shape (8, ) in Float32.",
168 return control_grid.Deform(pcd);
170 "Non-rigidly deform a point cloud using the control grid.",
178 return control_grid.Deform(depth, intrinsics,
179 extrinsics, depth_scale,
182 "Non-rigidly deform a depth image by "
183 "\n- unprojecting the depth image to a point cloud "
184 "\n- deform the point cloud; "
185 "\n- project the deformed point cloud back to the image. ",
186 "depth"_a,
"intrinsics"_a,
"extrinsics"_a,
"depth_scale"_a,
195 return control_grid.Deform(rgbd, intrinsics, extrinsics,
196 depth_scale, depth_max);
198 "Non-rigidly deform a RGBD image by "
199 "\n- unprojecting the RGBD image to a point cloud "
200 "\n- deform the point cloud; "
201 "\n- project the deformed point cloud back to the image. ",
202 "rgbd"_a,
"intrinsics"_a,
"extrinsics"_a,
"depth_scale"_a,
205 "Get control grid original positions directly from tensor "
208 "Get control grid shifted positions from tensor values "
209 "(optimized in-place)")
213 return *control_grid.GetHashMap();
215 "Get the control grid hashmap.")
221 "ControlGrid[size={:d}, "
223 control_grid.Size(), control_grid.GetAnchorIdx());
226 "save_correspondences_for_pointclouds",
228 py::call_guard<py::gil_scoped_release>(),
229 "Read pose graph containing loop closures and odometry to compute "
230 "correspondences. Uses aggressive pruning -- reject any suspicious "
232 "fnames_processed"_a,
"fragment_pose_graph"_a,
240 "Simultaneous Localization and Calibration: Self-Calibration of "
241 "Consumer Depth Cameras, CVPR 2014 Qian-Yi Zhou and Vladlen Koltun "
242 "Estimate a shared control grid for all fragments for scene "
243 "reconstruction, implemented in "
244 "https://github.com/qianyizh/ElasticReconstruction. ",
245 "fragment_filenames"_a,
"fragment_pose_graph"_a,
253 "Extended ICP to simultaneously align multiple point clouds with "
254 "dense pairwise point-to-plane distances.",
255 "fragment_filenames"_a,
"fragment_pose_graph"_a,
filament::Texture::InternalFormat format
cmdLineReadable * params[]
The Image class stores image with customizable rows, cols, channels, dtype and device.
A point cloud contains a list of 3D points.
RGBDImage A pair of color and depth images.
core::Tensor GetInitPositions()
Get control grid original positions directly from tensor keys.
std::tuple< core::Tensor, core::Tensor, core::Tensor > GetNeighborGridMap()
core::Tensor GetCurrPositions()
void FunctionDocInject(py::module &pybind_module, const std::string &function_name, const std::unordered_map< std::string, std::string > &map_parameter_body_docs)
void SaveCorrespondencesForPointClouds(const std::vector< std::string > &fnames_processed, const PoseGraph &pose_graph, const SLACOptimizerParams ¶ms, const SLACDebugOption &debug_option)
Read pose graph containing loop closures and odometry to compute putative correspondences between pai...
PoseGraph RunRigidOptimizerForFragments(const std::vector< std::string > &fnames, const PoseGraph &pose_graph, const SLACOptimizerParams ¶ms, const SLACDebugOption &debug_option)
Extended ICP to simultaneously align multiple point clouds with dense pairwise point-to-plane distanc...
static const std::unordered_map< std::string, std::string > map_shared_argument_docstrings
std::pair< PoseGraph, ControlGrid > RunSLACOptimizerForFragments(const std::vector< std::string > &fnames, const PoseGraph &pose_graph, const SLACOptimizerParams ¶ms, const SLACDebugOption &debug_option)
Simultaneous Localization and Calibration: Self-Calibration of Consumer Depth Cameras,...
void pybind_slac(py::module &m)
Generic file read and write utility for python interface.
int debug_start_node_idx_
int max_iterations_
Number of iterations.
core::Device device_
Device to use.
float distance_threshold_
Distance threshold to filter inconsistent correspondences.
float regularizer_weight_
Weight of the regularizer.
std::string slac_folder_
Relative directory to store SLAC results in the dataset folder.
float fitness_threshold_
Fitness threshold to filter inconsistent pairs.