用opencv库来检测ros深度图像数据中的障碍

深度摄像头数据障碍检测用深度图像数据检测障碍cv::threshold(depthMat, threshold_output, 20, 255, CV_THRESH_BINARY);cv::findContours(threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0));cv::convexHull(cv::Mat(contours[i]), hull[i], fals
摘要由CSDN通过智能技术生成

获得深度图像数据,转成cv::Mat格式

cv::Mat depthMat(depthi->getHeight(), depthi->getWidth (),  CV_16UC1, depth_map);

清除1米外的数据

int nr = depthMat.rows; // number of rows 
int nc = depthMat.cols; // number of columns 
for (int i = 0; i<nr; i++)
{
    for (int j = 0; j<nc; j++) {
        if (depthMat.at<ushort>(i, j)>1000){
            depthMat.at<ushort>(i, j) = 0;
        }
    }
}

将像素16U数据转成8U数据

depthMat.convertTo(depthMat, CV_8UC1, 1.0 / 16);

正常来说因子应该为 256/65536=1/256。16表示16×256=4096,可测障碍最远为4.096米,而1米外的障碍已清楚,图像像素最大深度肯定小于1000,因此因子为1/16可将图像上的所有障碍保留下来。


用阈值函数将图像中的障碍显示到一个平面中

cv::Mat threshold_output;
cv::threshold(depthMat, thr
  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值