PCL学习之获取点云

刚入门学习PCL点云库,有些基础东西比较茫然。比如已经存在由RGB-D sensor获取的rgb image和depth image,如何将其转化为点云。下面,以比较通用的点云类型pcl::PointXYZRGB为例,讲述如何获取对应的点云数据。

**

code:

**
pcl::PointCloud::Ptr depth2cloud( cv::Mat rgb_image, cv::Mat depth_image )
{
float f = 570.3;
float cx = 320.0, cy = 240.0;

pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_ptr( new     pcl::PointCloud<pcl::PointXYZRGB> () );
cloud_ptr->width  = rgb_image.cols;
cloud_ptr->height = rgb_image.rows;
cloud_ptr->is_dense = false;

for ( int y = 0; y < rgb_image.rows; ++ y ) {
    for ( int x = 0; x < rgb_image.cols; ++ x ) {
        pcl::PointXYZRGB pt;
        if ( depth_image.at<unsigned short>(y, x) != 0 )
        {
            pt.z = depth_image.at<unsigned short>(y, x)/1000.0;
            pt.x = (x-cx)*pt.z/f;
            pt.y = (y-cy)*pt.
  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值