#include<pcl/point_cloud.h>
#include<pcl/point_types.h>
#include<pcl/visualization/pcl_visualizer.h> //cout endl
#include <pcl/common/file_io.h>
typedef pcl::PointXYZ PointT;
int main()
{
//(1)查找目錄下所有 *.pcd 文件并排序返回
//void pcl::getAllPcdFilesInDirectory(const std::string &directory, std::vector< std::string > &file_names)
std::vector<std::string> file_names;
pcl::getAllPcdFilesInDirectory("./", file_names);
//(2)從給定字符串中刪除路徑,只返回文件名(后面的剩余字符串最后一個(gè)'/')
//std::string pcl::getFilenameWithoutPath(const std::string &input)
std::string path = "D://source//PLC_TestDemo_PalletHole_V1.0_new//bunny.pcd";
std::string newPath = pcl::getFilenameWithoutPath(path);
//(3)從給定字符串中刪除擴(kuò)展名并僅返回文件名(最后一個(gè)'.'之前的所有內(nèi)容)
//std::string pcl::getFilenameWithoutExtension (const std::string &input)
std::string newPathWithoutExtension = pcl::getFilenameWithoutExtension(newPath);
//(4)從給定的字符串中獲取文件擴(kuò)展名(最后一個(gè)'.'之后的剩余字符串)
//std::string pcl::getFileExtension (const std::string &input)
std::string newFileExtension = pcl::getFileExtension(path);
system("pause");
return 0;
}
參考文章:
http://pointclouds.org/documentation/common_2include_2pcl_2common_2file__io_8h.html
http://pointclouds.org/documentation/common_2include_2pcl_2common_2file__io_8h_source.html