[visualization] PCLVisualizer::addCorrespondences/updateCorrespondences does not show all correspondences
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- cpp
调研方向
从 mwe.cpp 复现程序以及 visualization/include/pcl/visualization/impl/pcl_visualizer.hpp 中的 addCorrespondences()/updateCorrespondences() 实现开始,包括第 1259 行附近被引用的区域。将其渲染行为与正常工作的 addLine() 循环进行比较,并调查为什么并非每个迭代到的对应关系都会变得可见;当所有对应关系都通过对应关系 API 显示出来时即视为完成。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
I use Registration::registerVisualizationCallback() to show correspondences. The code employs PCLVisualizer::addCorrespondences(). This does not lead to all correspondences getting shown. If instead I iterate over all correspondences manually and addLine() for each, all are shown as expected. Somewhere inside PCLVisualizer, items get lost.
Expected behavior
All correspondences passed to addCorrespondences() function should be shown.
Current Behavior
Not all correspondences passed to addCorrespondences() function are shown.
To Reproduce
mwe.cpp
#include <pcl/io/pcd_io.h>
#include <pcl/registration/icp.h>
#include <pcl/visualization/pcl_visualizer.h>
using namespace std;
using namespace pcl;
using namespace pcl::visualization;
using PointT = PointXYZ;
using CloudT = PointCloud<PointT>;
using namespace Eigen;
struct RegistrationVisualizer {
pcl::visualization::PCLVisualizer::Ptr optimization_viewer;
RegistrationVisualizer();
void visualize_registration(pcl::Registration<PointT, PointT> ®);
};
int main(int argc, char *argv[]) {
Matrix4f transformation;
transformation << 1, 0, 0, 6.7, 0, 1, 0, 12.3, 0, 0, 1, 0.7, 0, 0, 0, 1;
CloudT::Ptr source{new CloudT};
CloudT::Ptr target{new CloudT};
io::loadPCDFile("../scene_filtered.pcd", *target);
io::loadPCDFile("../template.pcd", *source);
IterativeClosestPoint<PointT, PointT> icp;
icp.setInputSource(source);
icp.setInputTarget(target);
icp.setMaxCorrespondenceDistance(0.1);
RegistrationVisualizer regvis;
regvis.visualize_registration(icp);
icp.align(*source, transformation);
return 0;
}
RegistrationVisualizer::RegistrationVisualizer() {
optimization_viewer = pcl::make_shared<pcl::visualization::PCLVisualizer>();
optimization_viewer->setWindowName("Correspondences");
}
void RegistrationVisualizer::visualize_registration(
pcl::Registration<PointT, PointT> ®) {
using namespace pcl;
using namespace pcl::visualization;
std::function<
pcl::Registration<PointT, PointT>::UpdateVisualizerCallbackSignature>
callback([this](const CloudT &c1, const pcl::Indices &idxs1,
const CloudT &c2, const pcl::Indices &idxs2) {
if (!idxs1.size() || !idxs2.size()) {
return;
}
// turn idxs into one correspondence vector
Correspondences correspondences;
for (size_t i = 0; i < idxs1.size(); ++i) {
correspondences.push_back(Correspondence(idxs1[i], idxs2[i], 1));
}
// viewer needs ptrs, not values (expensiveish)
const CloudT::Ptr c1_correspondences = c1.makeShared();
const CloudT::Ptr c2_correspondences = c2.makeShared();
if (!this->optimization_viewer->updatePointCloud<PointT>(
c1_correspondences, "c1")) {
this->optimization_viewer->addPointCloud<PointT>(c1_correspondences,
"c1");
this->optimization_viewer->setPointCloudRenderingProperties(
PCL_VISUALIZER_COLOR, 0, 1, 1, "c1");
this->optimization_viewer->setPointCloudRenderingProperties(
PCL_VISUALIZER_POINT_SIZE, 3, "c1");
}
if (!this->optimization_viewer->updateText("Source", 10, 10)) {
this->optimization_viewer->addText("Source", 10, 10, 20, 0, 1, 1);
}
if (!this->optimization_viewer->updatePointCloud<PointT>(
c2_correspondences, "c2")) {
this->optimization_viewer->addPointCloud<PointT>(c2_correspondences,
"c2");
this->optimization_viewer->setPointCloudRenderingProperties(
PCL_VISUALIZER_COLOR, 1, 1, 0, "c2");
this->optimization_viewer->setPointCloudRenderingProperties(
PCL_VISUALIZER_POINT_SIZE, 3, "c2");
}
if (!this->optimization_viewer->updateText("Target", 10, 40)) {
this->optimization_viewer->addText("Target", 10, 40, 20, 1, 1, 0);
}
// works as expected
/* int c = 0; */
/* for (const auto& corr : correspondences) { */
/* const auto p1 = c1_correspondences->points[corr.index_query]; */
/* const auto p2 = c2_correspondences->points[corr.index_match]; */
/* const string name = "line" + to_string(c); */
/* this->optimization_viewer->removeShape(name); */
/* this->optimization_viewer->addLine(p1, p2, 1, 0, 0, name); */
/* c++; */
/* } */
// many lines missing
if (!this->optimization_viewer->updateCorrespondences<PointT>(
c1_correspondences, c2_correspondences, correspondences)) {
this->optimization_viewer->addCorrespondences<PointT>(
c1_correspondences, c2_correspondences, correspondences,
"correspondences");
}
this->optimization_viewer->setShapeRenderingProperties(
PCL_VISUALIZER_LINE_WIDTH, 5, "correspondences");
this->optimization_viewer->spin();
});
reg.registerVisualizationCallback(callback);
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.19.8)
set(CMAKE_CXX_STANDARD 20)
find_package(PCL REQUIRED)
add_executable(mwe mwe.cpp)
target_link_libraries(mwe ${PCL_LIBRARIES})
target_include_directories(mwe PRIVATE ${PCL_INCLUDE_DIRS})
pcds:
First screenshot is using updateCorrespondences(). Notice how on the right there are no correspondences.
Second screenshot I add them by hand with addLine(). Many correspondences on the right.
Your Environment (please complete the following information):
- OS: macos 12.6.5
- Compiler: Apple clang version 14.0.0 (clang-1400.0.29.202) (arm)
- PCL Version 1.13 (4d8f60706c5d97c4a5b3b3da65f107cc7716ce1e)
I'm at a loss here. I don't know VTK, but the code in addCorrespondences() does not look wrong. I could verify that in https://github.com/PointCloudLibrary/pcl/blob/master/visualization/include/pcl/visualization/impl/pcl_visualizer.hpp#L1259, the full number of found correspondences is iterated, but somehow not everything shows up.
This led me on a merry chase as I had first assumed the correspondence estimation to somehow fail, but it seems to be just the visualization.
- 主要语言
- C++
- 星标
- 11.2k
- 派生
- 4.7k
- 平均合并
- 6 天 13 小时
- 30 天内合并 PR
- 10
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PointCloudLibrary/pcl 的其他 Issue
-
kind: bug status: triage
难度 1/5 1 小时以内 新手友好度 82/100
PointCloudLibrary/pcl#6536 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
PointCloudLibrary/pcl#6509 · 1 条评论 ·
维护者通常 3 天内回复
-
kind: bug status: triage
难度 4/5 3-5 天 新手友好度 48/100
PointCloudLibrary/pcl#6537 ·
维护者通常 3 天内回复
-
[cmake] QHULL/FLANN dll missing when linking single module可能已有人在做 @SIDDARTHAREDDY8 于 6 天前认领。 未关闭kind: bug module: cmake
难度 3/5 半天 新手友好度 50/100
PointCloudLibrary/pcl#6522 · 1 条评论 ·
维护者通常 3 天内回复
-
kind: bug status: triage
难度 4/5 3-5 天 新手友好度 35/100
PointCloudLibrary/pcl#6395 ·
维护者通常 3 天内回复
查看 PointCloudLibrary/pcl 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
HarperFast/rocksdb-js#1131 ·
维护者通常 1 天内回复
-
area/daemon bug good first issue platform/linux priority/p2
难度 2/5 1-3 小时 新手友好度 72/100
ToshiNamura/Deimos#5 ·
-
needs-format
难度 2/5 1-3 小时 新手友好度 82/100
Niko1221/Strata#6251 · 1 条评论 ·
维护者通常 5 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
metasequoiaime/msime#11666 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
patrick-hudson/put.gd-desktop#1679 · 1 条评论 ·
维护者通常 1 天内回复