Skip to content

Commit

Permalink
Replacing test data with dataset in Benchmarks and Examples (isl-org#…
Browse files Browse the repository at this point in the history
  • Loading branch information
reyanshsolis authored Feb 27, 2022
1 parent 61233d4 commit c957100
Show file tree
Hide file tree
Showing 21 changed files with 182 additions and 588 deletions.
2 changes: 1 addition & 1 deletion docs/jupyter/pipelines/rgbd_integration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"This tutorial uses the function `read_trajectory` to read a camera trajectory from a [.log file](http://redwood-data.org/indoor/fileformat.html). A sample `.log` file is as follows.\n",
"\n",
"```\n",
"# examples/test_data/RGBD/odometry.log\n",
"# odometry.log\n",
"0 0 1\n",
"1 0 0 2\n",
"0 1 0 2\n",
Expand Down
93 changes: 4 additions & 89 deletions docs/jupyter/t_pipelines/t_icp_registration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,92 +91,6 @@
"Different variants of ICP use different objective functions $E(\\mathbf{T})$ [\\[BeslAndMcKay1992\\]](../reference.html#beslandmckay1992) [\\[ChenAndMedioni1992\\]](../reference.html#chenandmedioni1992) [\\[Park2017\\]](../reference.html#park2017)."
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"### Different variants of ICP"
]
},
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"#### Point-to-point ICP\n",
"\n",
"We first show a point-to-point ICP algorithm [\\[BeslAndMcKay1992\\]](../reference.html#beslandmckay1992) using the objective\n",
"\n",
"\\begin{equation}\n",
"E(\\mathbf{T}) = \\sum_{(\\mathbf{p},\\mathbf{q})\\in\\mathcal{K}}\\|\\mathbf{p} - \\mathbf{T}\\mathbf{q}\\|^{2}\n",
"\\end{equation}\n",
"\n",
"The class `TransformationEstimationPointToPoint` provides functions to compute the residuals and Jacobian matrices of the point-to-point ICP objective.\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"#### Point-to-plane ICP\n",
"The point-to-plane ICP algorithm [\\[ChenAndMedioni1992\\]](../reference.html#chenandmedioni1992) uses a different objective function\n",
"\n",
"\\begin{equation}\n",
"E(\\mathbf{T}) = \\sum_{(\\mathbf{p},\\mathbf{q})\\in\\mathcal{K}}\\big((\\mathbf{p} - \\mathbf{T}\\mathbf{q})\\cdot\\mathbf{n}_{\\mathbf{p}}\\big)^{2},\n",
"\\end{equation}\n",
"\n",
"where $\\mathbf{n}_{\\mathbf{p}}$ is the normal of point $\\mathbf{p}$. [\\[Rusinkiewicz2001\\]](../reference.html#rusinkiewicz2001) has shown that the point-to-plane ICP algorithm has a faster convergence speed than the point-to-point ICP algorithm.\n",
"\n",
"The class `TransformationEstimationPointToPlane` provides functions to compute the residuals and Jacobian matrices of the point-to-plane ICP objective. \n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Colored ICP\n",
"\n",
"Following [\\[Park2017\\]](../reference.html#park2017), it runs ICP iterations with a joint optimization objective\n",
"\n",
"\\begin{equation}\n",
"E(\\mathbf{T}) = (1-\\delta)E_{C}(\\mathbf{T}) + \\delta E_{G}(\\mathbf{T})\n",
"\\end{equation}\n",
"\n",
"where $\\mathbf{T}$ is the transformation matrix to be estimated. $E_{C}$ and $E_{G}$ are the photometric and geometric terms, respectively. $\\delta\\in[0,1]$ is a weight parameter that has been determined empirically.\n",
"\n",
"The geometric term $E_{G}$ is the same as the Point-to-plane ICP objective\n",
"\n",
"\\begin{equation}\n",
"E_{G}(\\mathbf{T}) = \\sum_{(\\mathbf{p},\\mathbf{q})\\in\\mathcal{K}}\\big((\\mathbf{p} - \\mathbf{T}\\mathbf{q})\\cdot\\mathbf{n}_{\\mathbf{p}}\\big)^{2},\n",
"\\end{equation}\n",
"\n",
"where $\\mathcal{K}$ is the correspondence set in the current iteration. $\\mathbf{n}_{\\mathbf{p}}$ is the normal of point $\\mathbf{p}$.\n",
"\n",
"The color term $E_{C}$ measures the difference between the color of point $\\mathbf{q}$ (denoted as $C(\\mathbf{q})$) and the color of its projection on the tangent plane of $\\mathbf{p}$.\n",
"\n",
"\\begin{equation}\n",
"E_{C}(\\mathbf{T}) = \\sum_{(\\mathbf{p},\\mathbf{q})\\in\\mathcal{K}}\\big(C_{\\mathbf{p}}(\\mathbf{f}(\\mathbf{T}\\mathbf{q})) - C(\\mathbf{q})\\big)^{2},\n",
"\\end{equation}\n",
"\n",
"where $C_{\\mathbf{p}}(\\cdot)$ is a precomputed function continuously defined on the tangent plane of $\\mathbf{p}$. Function$\\mathbf{f}(\\cdot)$ projects a 3D point to the tangent plane. For more details, refer to [\\[Park2017\\]](../reference.html#park2017).\n",
"\n",
"To further improve efficiency, [\\[Park2017\\]](../reference.html#park2017) proposes a multi-scale registration scheme. \n",
"\n",
"The class `TransformationEstimationForColoredICP` provides functions to compute the residuals and Jacobian matrices of the joint optimization objective. \n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -1032,7 +946,8 @@
"metadata": {},
"source": [
"---\n",
"# Point-To-Point ICP Registration \n",
"\n",
"## Point-To-Point ICP Registration \n",
"\n",
"We first show a point-to-point ICP algorithm [\\[BeslAndMcKay1992\\]](../reference.html#beslandmckay1992) using the objective\n",
"\n",
Expand Down Expand Up @@ -1171,7 +1086,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Point-to-Plane ICP Registration\n",
"## Point-to-Plane ICP Registration\n",
"The point-to-plane ICP algorithm [\\[ChenAndMedioni1992\\]](../reference.html#chenandmedioni1992) uses a different objective function\n",
"\n",
"\\begin{equation}\n",
Expand Down Expand Up @@ -1237,7 +1152,7 @@
"tags": []
},
"source": [
"# Colored ICP Registration\n",
"## Colored ICP Registration\n",
"This tutorial demonstrates an ICP variant that uses both geometry and color for registration. It implements the algorithm of [\\[Park2017\\]](../reference.html#park2017). The color information locks the alignment along the tangent plane. Thus this algorithm is more accurate and more robust than prior point cloud registration algorithms, while the running speed is comparable to that of ICP registration. "
]
},
Expand Down
4 changes: 2 additions & 2 deletions examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ if (BUILD_GUI)
open3d_add_example(Draw)
open3d_add_example(MultipleWindows Open3D::3rdparty_threads)
open3d_add_example(OffscreenRendering)
open3d_add_example(TICPOdometry Open3D::3rdparty_threads)
open3d_add_example(TICPReconstruction Open3D::3rdparty_threads)
open3d_add_example(TICPSequential Open3D::3rdparty_threads)
open3d_add_example(TICP Open3D::3rdparty_threads)
open3d_add_example(DenseSLAMGUI Open3D::3rdparty_threads)
endif()

Expand Down
15 changes: 8 additions & 7 deletions examples/cpp/CameraPoseTrajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void PrintHelp() {
PrintOpen3DVersion();
// clang-format off
utility::LogInfo("Usage:");
utility::LogInfo("> CameraPoseTrajectory [trajectory_file] [pcds_dir]");
utility::LogInfo("> CameraPoseTrajectory [trajectory_file]");
// clang-format on
utility::LogInfo("");
}
Expand All @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) {

if (argc == 1 ||
utility::ProgramOptionExistsAny(argc, argv, {"-h", "--help"}) ||
argc != 3) {
argc != 2) {
PrintHelp();
return 1;
}
Expand All @@ -62,12 +62,13 @@ int main(int argc, char *argv[]) {

camera::PinholeCameraTrajectory trajectory;
io::ReadPinholeCameraTrajectory(argv[1], trajectory);

data::DemoICPPointClouds sample_icp_data;
std::vector<std::shared_ptr<const geometry::Geometry>> pcds;
for (size_t i = 0; i < trajectory.parameters_.size(); i++) {
std::string buffer =
fmt::format("{}cloud_bin_{:d}.pcd", argv[2], (int)i);
if (utility::filesystem::FileExists(buffer.c_str())) {
auto pcd = io::CreatePointCloudFromFile(buffer.c_str());
for (size_t i = 0; i < 3; i++) {
if (utility::filesystem::FileExists(sample_icp_data.GetPaths()[i])) {
auto pcd =
io::CreatePointCloudFromFile(sample_icp_data.GetPaths()[i]);
pcd->Transform(trajectory.parameters_[i].extrinsic_);
pcd->colors_.clear();
if ((int)i < NUM_OF_COLOR_PALETTE) {
Expand Down
50 changes: 10 additions & 40 deletions examples/cpp/ColorMapOptimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,55 +30,31 @@

using namespace open3d;

void PrintHelp() {
using namespace open3d;

PrintOpen3DVersion();
// clang-format off
utility::LogInfo("Usage:");
utility::LogInfo("> ColorMapOptimization [data_dir]");
// clang-format on
utility::LogInfo("");
}

std::tuple<geometry::TriangleMesh,
std::vector<geometry::RGBDImage>,
camera::PinholeCameraTrajectory>
PrepareDataset(const std::string& data_path) {
PrepareDataset() {
data::SampleFountainRGBDImages fountain_rgbd;
// Read RGBD images
std::vector<std::string> depth_filenames, color_filenames;
utility::filesystem::ListFilesInDirectoryWithExtension(
data_path + "/depth/", "png", depth_filenames);
utility::filesystem::ListFilesInDirectoryWithExtension(
data_path + "/image/", "jpg", color_filenames);
if (depth_filenames.size() != color_filenames.size()) {
utility::LogError(
"The number of depth images {} does not match the number of "
"color images {}.",
depth_filenames.size(), color_filenames.size());
}
std::sort(depth_filenames.begin(), depth_filenames.end());
std::sort(color_filenames.begin(), color_filenames.end());

std::vector<geometry::RGBDImage> rgbd_images;
for (size_t i = 0; i < depth_filenames.size(); i++) {
utility::LogDebug("reading {}...", depth_filenames[i]);
auto depth = io::CreateImageFromFile(depth_filenames[i]);
utility::LogDebug("reading {}...", color_filenames[i]);
auto color = io::CreateImageFromFile(color_filenames[i]);
for (size_t i = 0; i < fountain_rgbd.GetDepthPaths().size(); i++) {
utility::LogDebug("reading {}...", fountain_rgbd.GetDepthPaths()[i]);
auto depth = io::CreateImageFromFile(fountain_rgbd.GetDepthPaths()[i]);
utility::LogDebug("reading {}...", fountain_rgbd.GetColorPaths()[i]);
auto color = io::CreateImageFromFile(fountain_rgbd.GetColorPaths()[i]);
auto rgbd_image = geometry::RGBDImage::CreateFromColorAndDepth(
*color, *depth, 1000.0, 3.0, false);
rgbd_images.push_back(*rgbd_image);
}

// Camera trajectory.
camera::PinholeCameraTrajectory camera_trajectory;
io::ReadPinholeCameraTrajectory(data_path + "/scene/key.log",
io::ReadPinholeCameraTrajectory(fountain_rgbd.GetKeyframePosesLogPath(),
camera_trajectory);

// Mesh.
geometry::TriangleMesh mesh;
io::ReadTriangleMesh(data_path + "/scene/integrated.ply", mesh);
io::ReadTriangleMesh(fountain_rgbd.GetReconstructionPath(), mesh);

return std::make_tuple(mesh, rgbd_images, camera_trajectory);
}
Expand All @@ -90,17 +66,11 @@ PrepareDataset(const std::string& data_path) {
int main(int argc, char* argv[]) {
utility::SetVerbosityLevel(utility::VerbosityLevel::Debug);

if (argc != 2 ||
utility::ProgramOptionExistsAny(argc, argv, {"-h", "--help"})) {
PrintHelp();
return 1;
}

// Read dataset.
geometry::TriangleMesh mesh;
std::vector<geometry::RGBDImage> rgbd_images;
camera::PinholeCameraTrajectory camera_trajectory;
std::tie(mesh, rgbd_images, camera_trajectory) = PrepareDataset(argv[1]);
std::tie(mesh, rgbd_images, camera_trajectory) = PrepareDataset();

// Save averaged color map (iteration=0).
pipelines::color_map::RigidOptimizerOption rigid_opt_option;
Expand Down
25 changes: 8 additions & 17 deletions examples/cpp/EvaluatePCDMatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ void PrintHelp() {
utility::LogInfo(" --gt file : A log file of the ground truth pairwise matching results. Must have.");
utility::LogInfo(" --threshold t : Distance threshold. Must have.");
utility::LogInfo(" --threshold_rmse t : Distance threshold to decide if a match is good or not. Default: 2t.");
utility::LogInfo(" --dir directory : The directory storing all pcd files. By default it is the parent directory of the log file + pcd/.");
utility::LogInfo(" --verbose n : Set verbose level (0-4). Default: 2.");
// clang-format on
}
Expand Down Expand Up @@ -118,27 +117,19 @@ int main(int argc, char *argv[]) {
utility::GetProgramOptionAsString(argc, argv, "--log");
std::string gt_filename =
utility::GetProgramOptionAsString(argc, argv, "--gt");
std::string pcd_dirname =
utility::GetProgramOptionAsString(argc, argv, "--dir");

double threshold =
utility::GetProgramOptionAsDouble(argc, argv, "--threshold");
double threshold_rmse = utility::GetProgramOptionAsDouble(
argc, argv, "--threshold_rmse", threshold * 2.0);
if (pcd_dirname.empty()) {
pcd_dirname =
utility::filesystem::GetFileParentDirectory(log_filename) +
"pcds/";
}

double threshold2 = threshold * threshold;
std::vector<std::string> pcd_names;
utility::filesystem::ListFilesInDirectoryWithExtension(pcd_dirname, "pcd",
pcd_names);
std::vector<geometry::PointCloud> pcds(pcd_names.size());
std::vector<geometry::KDTreeFlann> kdtrees(pcd_names.size());
for (size_t i = 0; i < pcd_names.size(); i++) {
io::ReadPointCloud(
pcd_dirname + "cloud_bin_" + std::to_string(i) + ".pcd",
pcds[i]);

data::DemoICPPointClouds sample_data;
std::vector<geometry::PointCloud> pcds(sample_data.GetPaths().size());
std::vector<geometry::KDTreeFlann> kdtrees(sample_data.GetPaths().size());
for (size_t i = 0; i < sample_data.GetPaths().size(); i++) {
io::ReadPointCloud(sample_data.GetPaths()[i], pcds[i]);
kdtrees[i].SetGeometry(pcds[i]);
}

Expand Down
Loading

0 comments on commit c957100

Please sign in to comment.