首页 > 解决方案 > 使用指定路径从目录加载 PCD 文件(路径包含作为文件名的字符串)

问题描述

我正在尝试从目录加载 pcd 文件,因此我正在获取文件名,然后将此文件名添加到路径中。

我知道文件名可以直接在路径中指定,但我这样做是因为文件名会有所不同。

      //getting the filename
      string ls = "3989440000.pcd"
      chdir("/home");
      path="/home/usr/pcd/" + ls;

    // Fill in the cloud data
       if (pcl::io::loadPCDFile<pcl::PointXYZ> (path.c_str(), *cloud) == -1) 
      {
        PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
        return (-1);
      }

这是我面临的错误。

[pcl::PCDReader::readHeader] 找不到文件'/home/usr/pcd/3989440000.pcd'。无法读取文件 test_pcd.pcd

标签: c++fileloadingpoint-cloud-librarypoint-clouds

解决方案


推荐阅读