//Record commonly used statements, add them as you use them
Table of contents
2. Determine whether the file exists
1. String splitting
the first method
/*
函数功能:将输入的字符串(或者从文件读取的)进行拆分,存放到vector向量中
参数一:待分割的字符串
参数二:以sep分割 例如sep=' '(空格),则以空格字符分割字符串
*/
vector<int> inputdata(string str,char sep)
{
vector<int> dataVec;//
//将输入的string类型进行字符分割,放入vector中
int flagSub = 0;
for (int i = 0; i < str.length(); i++)
{
if (str[i] == sep)
{
int temp = stof(str.substr(flagSub, i - flagSub));
//cout << "temp = " << temp << endl;
dataVec.push_back(temp);
flagSub = i + 1;
}
}
return dataVec;
}
2. Determine whether the file exists
//首先判断图片文件是否存在
const char* rgbexit = rgbpaths.data();
//access()函数----如果存在返回0,不存在返回-1
if (access(rgbexit, 0) == -1)//如果不存在,就返回
{
return 1;//return 1 说明没有图片
}
3. Convert string
//将int类型转换为字符串
int i = 5;
string path;
path = "F:\\Depth\\" + to_string(i)+".png";