我有一系列图像,从中提取了兴趣点。为了可视化整个云点,使用了 pcl 库。因此存在两个变量 p,它是从一个关键帧中提取的点云,而 globalMap 是所有云点的串联。
这是代码:
generatePointCloud(pKF);
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr p(new pcl::PointCloud<pcl::PointXYZRGBA>);
//Eigen::Matrix<double,4,4> Converter::toMatrix4d(const Sophus::SE3f &T)
pcl::transformPointCloud(*(pKF->mptrPointCloud), *(p), Converter::toMatrix4d(pKF->GetPoseInverse()));
{
std::unique_lock<std::mutex> lck(mMutexGlobalMap);
std::cout<<"MutexGlobalMap "<<std::endl;
if (globalMap == nullptr) {
std::cout<<"NUll pointer "<<std::endl;
} else {
std::cout<<"not empty "<<std::endl;
}
if (p == nullptr) {
std::cout<<"NULL POINTER "<<std::endl;
} else {
std::cout<<"not empty "<<std::endl;
}
if (p->size() > 0) {
std::cout<<" P size "<<std::endl;
cout<< p->size() <<endl;
} else {
cout<< p->size() <<endl;
}
if (globalMap->size() > 0) {
std::cout<<" global map size "<<std::endl;
cout<< globalMap->size() <<endl;
} else {
cout<< globalMap->size() <<endl;
}
// Check the type of globalMap Type of globalMap: N3pcl10PointCloudINS_12PointXYZRGBAEEE
std::cout << "Type of globalMap: " << typeid(*globalMap).name() << std::endl;
// Check the type of p Type of p: N3pcl10PointCloudINS_12PointXYZRGBAEEE
std::cout << "Type of p: " << typeid(*p).name() << std::endl
*globalMap += *p;
调试消息给出以下结果:
Start processing sequence ...
Images in the sequence: 5178
First KF:0; Map init KF:0
New Map created with 575 points
receive a keyframe, 0
receive a keyframe, 1
receive a keyframe
MutexGlobalMap
not empty
not empty
P size
13415
0
Type of globalMap: N3pcl10PointCloudINS_12PointXYZRGBAEEE
Type of p: N3pcl10PointCloudINS_12PointXYZRGBAEEE
Added the point to the global map
tmp init
Setting Input Cloud
13415
receive a keyframe, 2
not empty
not empty
P size
13346
global map size
13415
Type of globalMap: N3pcl10PointCloudINS_12PointXYZRGBAEEE
Type of p: N3pcl10PointCloudINS_12PointXYZRGBAEEE
Segmentation fault (core dumped)
第一次加入全局地图后出现segmentation fault。它发生在这一行
*globalMap += *p;
调试器给出此消息:
Thread 4 "rgbd_tum" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffd75b7700 (LWP 72283)]
__GI___libc_free (mem=0xb6934) at malloc.c:3102
3102 malloc.c: No such file or directory.
预期的结果是一张包含所有关键帧的所有云点的全局地图。知道如何解决这个问题吗?