textfile, yaml등 텍스트 파일 안에 다양한 텍스처 정보가 들어있을텐데
필요한 정보만 추출하고싶을 때 쓸 수 있는 방법 입니다.
#include<fstream>
#include<string>
ifstream fTimes; //입력파일 선언
string tFile = "text.txt";
fTimes.open(tFile.c_str());
while(!fTimes.eof())
{
string s;
getline(fTimes,s); //텍스트 파일 내용 한줄씩 가져오기
if(!s.empty())
{
stringstream ss;
ss << s;
vector<string> words;
string word;
while (getline(ss, word, ' ')){
words.push_back(word);
}
}
}
fTimes.open(tFile.c_str()) : string 타입인 tFile을 const char* 타입으로 변환해줍니다.
getline(ss, word, ' ') : 한 줄 돌면서 공백으로 단어 구분
반응형
'자율주행 데브코스 4기 TIL > Computer Vision' 카테고리의 다른 글
Jetson nono에 CSI camera 연결 방법 (0) | 2023.02.12 |
---|