接上一篇。
步骤8:从rgb图和d图初始化点云,然后滤波(可选)
cout << "Initing...\n";
//初始化点云
vector<PointCloud::Ptr> pcVec;
for (int i = 0; i < keyVec.size(); i++) {
FRAME tframe;
tframe.rgb = cv::imread(rgbPathVec[i]);
tframe.depth = cv::imread(dPathVec[i], -1);
pcVec.push_back(image2PointCloud(tframe.rgb, tframe.depth, camera));
}
cout << "Filtering...\n";
//滤波
bool bFilter = true;
if (bFilter) {
for (auto& pciter : pcVec) {
PointCloud::Ptr cloud_filtered(new PointCloud());
pcl::VoxelGrid<pcl::PointXYZRGBA> sor;
sor.setInputCloud(pciter);
sor.setLeafSize(0.01f, 0.01f, 0.01f);
sor.filter(*cloud_filtered);
pciter = cloud_filtered;
PointCloud::Ptr cloud_filtered2(new PointCloud());
pcl::StatisticalOutlierRemoval<pcl::PointXYZRGBA> sor2;
sor2.setInputCloud(cloud_filtered);
sor2.setMeanK(50);
sor2.setStddevMulThresh(1.0);
sor2.filter(*cloud_filtered2);
pciter = cloud_filtered2;
}
}
初始化点云使用了高博的image2PointCloud函数,滤波使用了PCL官方教程上的体素滤波和离散值滤波,之前都有提过链接。
现在,pcVec中有了每个滤过波的关键帧的点云了。
步骤9:使用关键帧文件信息进行点云拼接
这一部分最会出坑的地方是对于输