1 | initial version |
You can refer to OpenCV samples. Many samples use this such concept. Here is one from \opencv\sources\samples\cpp\stereo_calib.cpp.
Following code opens the text file and prepares the list of file names.
FILE* f = fopen("ImageList.txt", "r");
vector<string> imagelist;
for(int i = 0; ; i++)
{
if(!fgets(buf, sizeof(buf)-3, f))
break;
size_t len = strlen(buf);
while(len > 0 && isspace(buf[len-1]))
buf[--len] = '\0';
if(buf[0] == '#')
continue;
imagelist.push_back(buf);
}
fclose(f);
Start accessing images by imread(imagelist[i])