我正在处理从两个图像中获取的深度图(我从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区域增长分段 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?
PS对不起我的写作错误.英语不是我的母语
UPD
我试图通过在mat_to_cloud函数中使用循环来“恢复”深度图
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++; } }
还有另一种循环顺序
int counter = 0;
cv :: Mat to_show = cv :: Mat :: zeros(288,cv :: DataType :: type);
for(int j = 0; j< cloud-> width; j)
{
for(int i = 0; i< cloud-> height; i)
{
to_show.at(i,j)= cloud-> at(counter).z;
反
}
}
我不知道为什么这些图像是相似的
解决方法
我之前没有使用PCL,但看起来这行可能是错误的:
// regions in this Mat must be equal with regions from depth map to_show.data[clusters[j].indices[i]] = 200;
to_show是一个opencv矩阵,但您使用点云中的索引.您需要先将索引转换为像素坐标.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。