c – 在rgb图像中使用来自点云的聚簇索引
发布时间:2020-12-16 07:04:23 所属栏目:百科 来源:网络整理
导读:我正在处理从两个图像中获取的深度图(我从opencv StereoBM中获取),现在我需要在它们中找到簇 我决定使用pcl区域增长分段 http://www.pointclouds.org/documentation/tutorials/region_growing_segmentation.php.我在阅读本文 http://blog.martinperis.com/20
我正在处理从两个图像中获取的深度图(我从opencv StereoBM中获取),现在我需要在它们中找到簇
我决定使用pcl区域增长分段 http://www.pointclouds.org/documentation/tutorials/region_growing_segmentation.php.我在阅读本文 http://blog.martinperis.com/2012/01/3d-reconstruction-with-opencv-and-point.html之后将cv :: Mat转换为点云,现在我有了集群索引 这在 https://gist.github.com/Daiver/5586252这里起作用 现在我想要使用这些索引在StereoBM(cv :: Mat)的深度图上显示簇 我正在尝试这个,但我对结果不满意 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud; //cloud from depth map and rgb image std::vector <pcl::PointIndices> clusters;// clusters inices,extracted before for(int j = 0; j < clusters.size(); j++) { cv::Mat to_show = cv::Mat::zeros(288,384,cv::DataType<uchar>::type);//image has size that equal size of rgb image and depth map for(int i = 0; i < clusters[j].indices.size(); i++) { to_show.data[clusters[j].indices[i]] = 200;// regions in this Mat must be equal with regions from depth map } cv::imshow("",to_show); cv::waitKey(); } 结果 另一个集群 可视化的云 我如何将集群投射到cv :: Mat? UPD int counter = 0; cv::Mat to_show = cv::Mat::zeros(288,cv::DataType<uchar>::type); for(int i = 0; i < cloud->height; i++) { for(int j = 0; j < cloud->width; j++) { to_show.at<uchar>(i,j) = cloud->at(counter).z; counter++; } } 还有另一种循环顺序 我不知道为什么这些图像是相似的 解决方法
我之前没有使用PCL,但看起来这行可能是错误的:
// regions in this Mat must be equal with regions from depth map to_show.data[clusters[j].indices[i]] = 200; to_show是一个opencv矩阵,但您使用点云中的索引.您需要先将索引转换为像素坐标. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |